Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script removes old rc files in $HOME/.config/xfce4/desktop/
- # It keeps only the latest created
- # Get process id of all inotifywait procs watching
- # for moved_to events in $HOME/.config/xfce4/desktop/
- notify_pid=`ps -eo pid,cmd | grep "inotifywait -m $HOME/.config/xfce4/desktop/ -e moved_to" | grep -v grep | awk '{print $1}'`
- # kill any watching job if any
- for pid in $notify_pid; do
- kill -SIGKILL $pid
- wait $notify_pid >/dev/null 2>&1
- done
- cd $HOME/.config/xfce4/desktop
- sleep 2
- # When the icons are moved, temp file is created and moved to rc file
- # Watching for file moved_to event with inotify
- # inotifywait prints two lines, second one is ignored.
- inotifywait -m $HOME/.config/xfce4/desktop/ -e moved_to \
- | while read path action file && read dummy
- do
- # Nested loop lists all the rc files
- for rc_file in $HOME/.config/xfce4/desktop/*.rc
- do
- # echo "$rc_file" "${path}${file%.*}"
- # If the file is not the latest moved removes it
- [[ "$rc_file" != "${path}${file%.*}" ]] && rm -v "${rc_file}"
- done
- # makes the backup rc file
- # cp "${path}${file%.*}" "${path}${file%.*}.backup"
- # echo "${path}${file%.*}" >> last_file.log
- notify-send "icon position saved" "${path}${file%.*}" -i gtk-info -t 2000
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement