Skip to content

Instantly share code, notes, and snippets.

@knuxify
Created January 17, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knuxify/3b4409077081a8665463f6e5cf18b455 to your computer and use it in GitHub Desktop.
Save knuxify/3b4409077081a8665463f6e5cf18b455 to your computer and use it in GitHub Desktop.
#!/bin/bash
# drivelinker - short script to make symlinks of drives
# variables
refreshrate="5" # refresh rate in seconds
desktop="$HOME/Desktop" # user's desktop
mount="/run/media/$USER" # where the drives are mounted
while true; do
for link in $desktop/*
do
if ! [ -f $link ] && [ -L $link ]; then rm $link; fi
done
for drive in $mount/*
do
if ! [[ "$drive" = *"*" ]]; then
ln -s $drive $desktop/${drive/"$mount"/}
fi
done
sleep $refreshrate
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment