Skip to content

Instantly share code, notes, and snippets.

@jasonwryan
Created January 18, 2015 00:53
Show Gist options
  • Save jasonwryan/0df98a396af89bf82eb6 to your computer and use it in GitHub Desktop.
Save jasonwryan/0df98a396af89bf82eb6 to your computer and use it in GitHub Desktop.
Repopulate symlinks from udev rule
#!/usr/bin/env bash
# repopulate music links when drive plugged in
shopt -s nullglob
export DISPLAY=:0
export XAUTHORITY=/home/jason/.Xauthority
music=(/media/Apollo/Music/*)
find /home/jason/Music -type l -exec rm {} \;
for dirs in "${music[@]}"; do
ln -s "$dirs" /home/jason/Music/ 2>/dev/null
done
status1=$?
mpc update &>/dev/null
status2=$?
if [[ "$status1" -eq 0 && "$status2" -eq 0 ]]; then
printf "%s\n" "Music directory updated" | dzen2 -p 3
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment