Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Description: Show notification when workspace changes
- # Requires: awk, xfce4-notifyd, libnotify, wmctrl, trap
- exitStatusSuccess=0
- exitStatusFail=1
- scriptname=$(basename -- "$0")
- scriptname="${scriptname%.*}"
- thisScriptFull=$(readlink -f ${BASH_SOURCE[0]})
- thisScriptPathOnly=$(dirname ${thisScriptFull})
- # make sure that only one instance of this script is running per user
- lockfile=/tmp/.${scriptname}.$USER.lockfile
- if ( set -o noclobber; echo "locked" > "$lockfile" ) 2> /dev/null; then
- trap 'rm -f "${lockfile}"; exit $?' INT TERM EXIT
- echo "${scriptname} DEBUG: Locking succeeded" >&2
- sleep 3
- WKS_NUMBER=$(wmctrl -d | awk -v val='*' '$2==val{print $1}')
- while true
- do
- WKS_NUMBER_NEW=$(wmctrl -d | awk -v val='*' '$2==val{print $1}')
- if [ ${WKS_NUMBER} -ne ${WKS_NUMBER_NEW} ]; then
- WKS_NUMBER=${WKS_NUMBER_NEW}
- WKS_NAME=$(wmctrl -d | awk -v val='*' '$2==val{print $10}')
- NUM_DISPLAY=$(( ${WKS_NUMBER} + 1 ))
- notify-send -t 2000 -i cs-workspaces "Workspace Changed" "Workspace changed to \"${WKS_NAME}\" [${NUM_DISPLAY}]"
- fi
- sleep 0.5
- done
- # can't create lockfile - notify user and quit
- else
- echo "${scriptname} DEBUG: Lock failed, check for existing process and/or lock file and delete exiting: ${lockfile}." >&2
- exit ${exitStatusFail}
- fi
- exit ${exitStatusSuccess}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement