1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-03-18 18:07:45 +01:00
dotfiles/.local/bin/tools/wallpaper

37 lines
1.9 KiB
Plaintext
Raw Normal View History

2019-09-13 10:51:43 +02:00
#!/bin/sh
2020-03-27 17:31:53 +01:00
# Adapted from a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
2020-03-27 17:31:53 +01:00
[ -z "$WALLPAPER_DESKTOP" ] && wall_desk="${XDG_DATA_HOME:-$HOME/.local/share}/bg" || disk="$WALLPAPER_DESKTOP"
[ -z "$WALLPAPER_LOCK" ] && wall_desk="${XDG_DATA_HOME:-$HOME/.local/share}/lock" || disk="$WALLPAPER_LOCK"
case "$1" in
desktop) wall_desk="${XDG_DATA_HOME:-$HOME/.local/share}/bg"
trueloc="$(readlink -f "$2")" &&
case "$(file --mime-type -b "$trueloc")" in
image/* ) ln -f "$(readlink -f "$2")" "$wall_desk" && notify-send -i "$wall_desk" "Desktop wallpaper has been changed." ;;
inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$wall_desk" && notify-send -i "$wall_desk" "Random desktop wallpaper chosen." ;;
*) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;;
esac
xwallpaper --zoom "$wall_desk" ;;
lock) wall_lock="${XDG_DATA_HOME:-$HOME/.local/share}/lock"
trueloc="$(readlink -f "$2")" &&
case "$(file --mime-type -b "$trueloc")" in
image/* ) ln -f "$(readlink -f "$2")" "$wall_lock" && notify-send -i "$wall_lock" "Lock screen wallpaper has been changed." ;;
inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$wall_lock" && notify-send -i "$wall_lock" "Random lock screen wallpaper chosen." ;;
*) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;;
esac ;;
*) cat << EOF
wallpaper: cli script to set and reset the wallpaper of the desktop and lock
screen.
2020-03-27 17:31:53 +01:00
Allowed options:
desktop [PATH] Set the wallpaper of the desktop to the specified path.
If no path is given reset it.
lock [PATH] Set the wallpaper of the lock screen to the specified path.
If no path is given reset it.
all else Print this message
2020-03-27 17:31:53 +01:00
EOF
esac