Posts Tagged ‘bash’

On our last party, I started using my old webcam to make a picture every 5 minutes to document the fun we were having. I used camorama, which has a build in feature to do exactly that.

Today I wanted to do the same with the webcam on my girlfriends netbook. UNR comes with Cheese, which does not have the ability to take pictures in regular intervals, but it worked out  of the box. I installed camorama, but for some reason it did not work.

After some debugging it still didn’t work so I though: this is Linux, there must be an easy hack to make Cheese take pictures automatically, and there is:

cheese& while true; do xvkbd -text " "; sleep 300; done

Running this in bash/a terminal will start Cheese and then simulate pressing the space key every 5 minutes. And Space is the shortcut for Take a photo. Of course you can’t do anything else on the netbook while this is running since Cheese has to be focused for this to work (There probably is a hack to fix that too).

Linux rocks!


Read Full Post »


I always had the problem that I couldn’t decide if I should use autostart to start things like kmail and kopete. On the one hand I don’t want to start 10 apps manually at 7am but on the other hand I really hate that everything autostarts in other situations like restarting KDE because of debugging my X11 config.

So finally I found a good solution (which is also desktop environment independent):

if kdialog --yesno "Autostart?"
  echo "Autostarting"
  akregator --hide-mainwindow
  basket --start-hidden

I start this script with the normal autostart routine of KDE, an now I’ve got a simple popup asking me if this particular time I want to autostart. Super nice.

Read Full Post »

KDE notifications + MPD

To get mpd to show the currently playing song, one can easily use kdialog:

kdialog --title "Currently playing song" --passivepopup "`mpc | head -n1`" 3

which triggers a KDE notification popup for 3 seconds. Not very pretty, but it’s simple and can be triggered via xbindkeys or something similar.

Read Full Post »

As with Amarok it’s not possible to delete the currently playing song in the MPD with any client I know. So again here’s my script. This time with a lot more error control 😉

# Change this to your mpd music directory.
if ! mpc &> /dev/null
        echo "mpc wasn't found. Please install first."
        exit 1
if [[ `mpc | wc -l` != 3 ]]
        echo 'There is no song playing right now...'
        exit 2
if [[ -z $MUSICTRASH ]]
        echo 'Please set $MUSICTRASH.'
        echo '  For example add this line to your .bashrc:'
        echo '  export MUSICTRASH=~/music/.trash'
        exit 3
if ! [[ -d $MUSICTRASH ]]
        echo "$MUSICTRASH does not exist."
        exit 4
file=`mpc --format '%file%' | head -n1`
if [[ -f $path ]]
        name=`basename "$path"`
        mpc del 0
        mv "$path" "$MUSICTRASH/"
        echo "'$name' moved to '$MUSICTRASH'"

Also set the config variable where you want to move your trashed music files:

File: .bashrc

export MUSICTRASH=~/music/.trash


TIP: Use xbindkeys if you need fast, easy and desktop-environment-independent global shortcuts.

Read Full Post »

A little bash script takes care of deleting the current song, you just have to setup a shortcut somewhere.

path=`dcop amarok player path`
if [[ $path != "" ]] # if player is currently stopped
        name=`basename "$path"`
        mv "$path" "$MUSICTRASH/$name"
        echo "Song moved to $MUSICTRASH" # output for usage in terminal
        dcop amarok player next # play next song to notify that something has happend

And set the config variable where you want to move your trashed music files:

File: .bashrc

export MUSICTRASH="/mnt/data/music/.trash"

bash is so powerful, it’s always a pleasure 😉

Read Full Post »