Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- NAME_FILE="/home/bladt/Downloads/walls/in_use/names.txt"
- DIR=$(dirname $NAME_FILE)
- WAIT_TIME="5m"
- STAT=0
- # takes a string as "[path] [option]"
- #+ and outputs "[flag] [path]" to be passed to awsetbg
- function modeSwitch {
- case $2 in
- "full")
- local mode="-F"
- ;;
- "centered")
- local mode="-C"
- ;;
- "tiled")
- local mode="-T"
- ;;
- "maximized")
- local mode="-A"
- ;;
- *)
- local mode="-F" #defaults to fullscreen
- ;;
- esac
- echo "$mode $1"
- }
- if [ "$#" -ne "0" ]; then
- IFS=$(echo -ne "\\n")
- name=$(grep -E "$1" $NAME_FILE)
- nonempty=$?
- if [ $(echo $name | wc -l) -gt "1" ]; then
- echo $name
- elif [ $nonempty -eq "0" ]; then
- unset IFS #unset here, to force $name to be split into modeSwitch's $1 and $2
- awsetbg $(modeSwitch $DIR/$name)
- else
- echo "wallrotor found no entries matching \"$1\"" >&2
- stat=1
- fi
- unset IFS
- exit $stat
- elif ps -e | grep -i wallrotor | grep -v $$ >/dev/null 2>&1 ; then
- echo "allready running"
- exit
- fi
- while true; do
- names="$(sort -R $NAME_FILE)"
- while read -r line ; do
- awsetbg $(modeSwitch $DIR/$line)
- sleep $WAIT_TIME
- done <<< "$names"
- done
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement