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: \""
- ws[2]="\"2: \""
- 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 () {
- lastws=$(cat ~/.i3/.ws )
- currentws=$(i3-msg -t get_workspaces | jq -c '.[] |select(.focused)|.name' )
- if [[ "$lastws" != "$currentws" ]] ; then
- echo "$currentws" >| ~/.i3/.ws
- for ((i=1;i<=10;i++)) ; do
- if [[ "${ws[$i]}" == "$currentws" ]] ; then
- currentIndex=$i
- if (($currentIndex !=10)) && [[ "$lastws" == ${ws[10]} ]]
- then
- #some personal stuff
- fi
- return "$currentIndex"
- fi
- done
- fi
- return 0
- }
- i=0
- while true ; do
- getws
- index=$?
- if (($index != 0 || $i >= 30 )) ; then
- if (($index !=0 )) ; then lasti=$index ; fi
- $HOME/.i3/wchanger.sh $lasti #script to change wallpaper if ws changed or 30s passed
- i=0
- fi
- i=$((i+1))
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement