Thursday, September 29, 2022

Using cron to schedule GUI programs

I needed to schedule a GUI program . I chose cron to do it however cron is not meant to schedule GUI programs . Cron does not know anything about user environments so u'd need to pass vars to it. For example the $DISPLAY env  var   


To edit/create a local crontab

crontab -e 

Here I am running a GUI program at 12:15 AM and terminating it at 5:50 AM ( there are better ways to terminate though ;) )

15 00 * * * DISPLAY=:0 /usr/bin/somegui

50 05 * * *  /usr/bin/pkill somegui

Sunday, September 18, 2022

Trivial line for Splitting file names

 

I have a Bluetooth speaker with USB support. Come next storm ( and power disruption) I have one pen drive full of classic rock songs . The problem is they are named as such " Artist - Song.mp3  and in the dir, they play alphabetically .. ah darn .. all AC/DC songs at one go.. lets change the file names as such "song.mp3" :-)

 

 for i in *.mp3 ; do  mv -v "$i" "${i#* -}"  ; done


does the trick . Bash pattern matching