Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- scriptname=$( basename "$0" )
- is_running=$( pgrep -cf "$scriptname" )
- if (( $is_running > 1 )) ; then
- >&2 echo $scriptname is running.
- exit 0
- fi
- declare -A ws=()
- ws[1]="\"1: root\""
- ws[2]="\"2: net\""
- ws[3]="\"3: Media\""
- ws[4]="\"4: Files\""
- ws[5]="\"5: Work\""
- ws[6]="\"6: Docs\""
- ws[7]="\"7\""
- ws[8]="\"8\""
- ws[9]="\"9\""
- ws[10]="\"10\""
- function getws () {
- lastWorkSpace=$(cat ~/.i3/.ws )
- WorkSpaceName=$(i3-msg -t get_workspaces | jq -c '.[] |select(.focused)|.name' )
- for ((i=1;i<=10;i++)) ; do
- if [[ "${ws[$i]}" == "$WorkSpaceName" ]] ; then
- currentWorkSpace=$i
- break
- fi
- done
- if [[ "$lastWorkSpace" != "$currentWorkSpace" ]]
- then
- echo "$currentWorkSpace" >| ~/.i3/.ws
- if (($currentWorkSpace !=10 && "$lastWorkSpace" == 10 )) ; then
- #here something to do when you just open ws 10
- fi
- if (($currentWorkSpace!=10)) ; then
- # some personal stuff
- fi
- if (($currentWorkSpace==10)) ; then
- #other personal stuf,
- fi
- return "$currentWorkSpace"
- else
- return 0
- fi
- return 0
- }
- #this is the engine that keeps running
- # every second it gets the current ws
- # change wallpaper every 30 s
- # or the second the ws changes
- ii=0
- while true ; do
- getws
- index=$?
- if (($index != 0 || $ii >= 30 )) ; then
- /home/mosaid/.i3/wchanger.sh
- ii=0
- fi
- ii=$((ii+1))
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement