Make commands independent of location on system
It helps running autorandr_nitrogen_wallpaper on systems without
/bin/bash, /usr/bin/unlink, /bin/cp and /bin/mv. E.g. NixOS, which
doesn't have /bin/bash.
# autorandr_nitrogen_wallpaper
# Copyright (c) 2015, Ondra 'Kepi' Kudlík, http://kepi.cz
# autorandr_nitrogen_wallpaper
# Copyright (c) 2015, Ondra 'Kepi' Kudlík, http://kepi.cz
PROFILE_BG_FILE="bg-saved.$PROFILE.cfg"
PROFILE_BG="$NITROGEN_HOME/$PROFILE_BG_FILE"
PROFILE_BG_FILE="bg-saved.$PROFILE.cfg"
PROFILE_BG="$NITROGEN_HOME/$PROFILE_BG_FILE"
+CP=$(which cp)
+MV=$(which mv)
+UNLINK=$(which unlink)
+NITROGEN=$(which nitrogen)
+
# save background for detected profile
if [[ $1 = 'savebg' ]]; then
# nitrogen config doesn't exist, instruct to run it first
# save background for detected profile
if [[ $1 = 'savebg' ]]; then
# nitrogen config doesn't exist, instruct to run it first
fi
# nitrogen config exists but is broken symlink, just remove it and instruct to run it first
if [ ! -e "$NITROGEN_BG" ] ; then
fi
# nitrogen config exists but is broken symlink, just remove it and instruct to run it first
if [ ! -e "$NITROGEN_BG" ] ; then
- /usr/bin/unlink "$NITROGEN_BG"
echo "wallpaper: you need to first run 'nitrogen' and set your wallpapers (config was broken)"
exit 3
fi
echo "wallpaper: you need to first run 'nitrogen' and set your wallpapers (config was broken)"
exit 3
fi
- /bin/cp -L "$NITROGEN_BG" "$PROFILE_BG"
+ $CP -L "$NITROGEN_BG" "$PROFILE_BG"
# load background for detected profile
else
# load background for detected profile
else
# nitrogen original file exists and not symlink
if [[ -f "$NITROGEN_BG" ]] && [[ ! -L "$NITROGEN_BG" ]]; then
echo "wallpaper: Backing up nitrogen saved bg to $NITROGEN_BG.backup"
# nitrogen original file exists and not symlink
if [[ -f "$NITROGEN_BG" ]] && [[ ! -L "$NITROGEN_BG" ]]; then
echo "wallpaper: Backing up nitrogen saved bg to $NITROGEN_BG.backup"
- /bin/mv "$NITROGEN_BG" "$NITROGEN_BG".backup
+ $MV "$NITROGEN_BG" "$NITROGEN_BG".backup
fi
# set symlink
echo "wallpaper: Found saved wallpaper for profile $PROFILE - changing"
ln -f -s "$PROFILE_BG_FILE" "$NITROGEN_BG"
# call nitrogen
fi
# set symlink
echo "wallpaper: Found saved wallpaper for profile $PROFILE - changing"
ln -f -s "$PROFILE_BG_FILE" "$NITROGEN_BG"
# call nitrogen
else
echo "wallpaper: No saved wallpaper found for profile $PROFILE"
fi
else
echo "wallpaper: No saved wallpaper found for profile $PROFILE"
fi