Skip to content

Instantly share code, notes, and snippets.

@V1ncNet
Forked from kiliankoe/cage.sh
Last active March 27, 2018 12:55
Show Gist options
  • Save V1ncNet/6944b322b9b865b27fb18754e8fb4c06 to your computer and use it in GitHub Desktop.
Save V1ncNet/6944b322b9b865b27fb18754e8fb4c06 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Supported desktop environments
# 1. Aqua (MacOS)
# 2. Gnome
# 3. Unity
# 4. Feh
# 5. xfce4
# 6. KDE
onError() {
echo -e " \u2639 Cannot cagify $1 desktop environment"
exit 1
}
if [ -z "$TMPDIR" ]; then
TMPDIR="/tmp"
fi
# [ -d $TMPDIR ] || mkdir $TMPDIR
curl -s -o $TMPDIR/cage.jpg https://user-images.githubusercontent.com/2625584/35465045-a69a87e2-02f9-11e8-98a3-10770c6a339f.jpg
if [ -x "$(command -v osascript)" ]; then
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$TMPDIR/cage.jpg\"" || onError "Aqua"
exit 0
fi
if [ -x "$(command -v gsettings)" ]; then
gsettings set org.gnome.desktop.background picture-uri file://$TMPDIR/cage.jpg || onError "Unity/GNOME"
exit 0
fi
if [ -x "$(command -v feh)" ]; then
feh -g 1920x1080 -d -S cage.jpg $TMPDIR || onError "Feh"
exit 0
fi
if [ -x "$(command -v xfconf-query)" ]; then
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s $TMPDIR/cage.jpg || onError "xfce4"
exit 0
fi
if [ -x "$(command -v dbus-send)"]; then
dbus-send --session --dest=org.kde.plasmashell --type=method_call /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:
var Desktops = desktops();
for (i=0;i<Desktops.length;i++) {
d = Desktops[i];
d.wallpaperPlugin = "org.kde.image";
d.currentConfigGroup = Array(
"Wallpaper",
"org.kde.image",
"General");
d.writeConfig("Image", '"file://$TMPDIR/cage.jpg"');
}' || onError "KDE"
fi
echo -e " \u2639 Your desktop environment isn't supported"
exit 1
@V1ncNet
Copy link
Author

V1ncNet commented Mar 27, 2018

I added KDE support. (untested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment