Skip to content

Instantly share code, notes, and snippets.

@leafo
Created March 29, 2016 08:06

Revisions

  1. leafo created this gist Mar 29, 2016.
    35 changes: 35 additions & 0 deletions hamster-dmenu.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/bin/sh

    function menu {
    dmenu -i -l 20 -fn 'Terminus-16' $@
    }

    function refreshawesome {
    echo 'require("leaf.status").refresh()' | awesome-client
    }

    current=$(hamster current)

    # choose an action
    if [ "No activity" = "$current" ]; then
    action="start"
    else
    action=$(echo -e -n "start\nstop $current" | menu -p Action)
    fi

    [ -z "$action" ] && exit 1

    case "$action" in
    start)
    activity=$(hamster activities | menu -p Start)
    [ -z "$activity" ] && exit 1
    hamster start "$activity"
    notify-send "Started $activity"
    refreshawesome
    ;;
    stop*)
    hamster stop
    notify-send "Stopped $current"
    refreshawesome
    ;;
    esac