snork.ca ... making kittens cry since 2001
homeabouttoscanaryrssmansvalidatecontact

guiat For Scheduling Linux Apps 2016-04-10


In Linux, if you want to schedule a command for a later time you would probably want to use the "at" command to set it up. But what if you want to run a graphical application instead of some script? Go on try it... it doesn't work so well does it? That's because it doesn't know which display to put the application on. Now you could just type in

export DISPLAY=:0

as the first line of your "at" session or you could type out your at command like this

echo "DISPLAY=:0.0 /usr/bin/qbittorrent" | at now + 30 minutes

but that sucks hard. So I made a script to schedule this kind of stuff and I am posting it here in hopes that someone else may care, or more likely... that I'll be able to find it quickly the next time I get annoyed with Debian and reinstall my OS. I don't claim to be an expert script writer, I just claim that this works for me and didn't cause any fires in the process.

/usr/bin/guiat #!/bin/bash
if [ "$#" -lt "2" ] ; then
   echo "You're doing it wrong."
   echo "guiat <gui-application> <timespec>"
   exit
else
   ATSUCKS=`which $1`
   echo $ATSUCKS
   echo -e "export DISPLAY=:0\n$ATSUCKS" | at $2 $3 $4 $5 $6 $7
fi

image Here's a whacky image I found at vignette4.wikia.nocookie.net.

I hope someone gets some joy out of this.

Made using Notepad++ & FastStone. Hosted on Debian with nginx & php. Powered by North Korean mushrooms.