Zenity GUI to a Shell Script

Published on Sunday, October 21, 2007

I have to admit, I'm pretty lazy. I don't (ironically) like to type, and I really don't like typing the same command over and over. I found myself switching between my external monitor and laptop quite frequently, and decided to somewhat automate the task. Although I know there are other programs out there that allow this, they either had too many features, or crashed. Xrandr works just fine, but like I said, I'm lazy...

Enter Zenity. Initially I created a PyGTK monitor switcher, yet wanted something even simpler. If you aren't in the know, Zenity allows you to create super fast, super simple dialogs to regular commands. After you click "ok", the command is executed, and the dialog disappears. Perfect for switching displays.

And here is the simplistic code behind it:


ans=$(zenity  --list  --text "How do you want to switch your monitor?" \
--radiolist  --column "Pick" --column "Output Type" TRUE LCD FALSE VGA \
FALSE Both);

if [ "$ans" = "LCD" ]
xrandr --output VGA --off
xrandr --output LVDS --auto
elif [ "$ans" = "VGA" ]
xrandr --output LVDS --off
xrandr --output VGA --auto
elif [ "$ans" = "Both" ]
xrandr --output VGA --auto
xrandr --output LVDS --mode 1024x768

I send a big cheers and thanks to the Zenity guys, I'll surely use this quick language more frequently.

Mass Spam Delete Django

Published on Tuesday, October 2, 2007

As you can read, I've been traveling around quite a bit lately. This means I haven't been checking the comments on my blog, which means quite a bit of spam has been entered. I am blocking the spam via akismet, however, it is still recorded in the database. Being somebody who hates cluttered desktops, you can imagine how I feel about having a lot (447) of spam. Well, since akismet flips the is_public switch True for good comments and False for bad comments, that makes a really easy query in mysql.

mysql> delete from comments_freecomment where is_public = False

Of course, make sure you have backed up your database first.