Skip to content

Instantly share code, notes, and snippets.

@kiliankoe
Last active June 17, 2019 12:13
Show Gist options
  • Save kiliankoe/9c0141df2de205789d5a75c9954cb49c to your computer and use it in GitHub Desktop.
Save kiliankoe/9c0141df2de205789d5a75c9954cb49c 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

V1ncNet commented Mar 26, 2018

I forked your awesome Gist. Checkout my version.

It's compatible with

  • Aqua
  • Gnome
  • Unity
  • Feh
  • xfce4

@kiliankoe
Copy link
Author

kiliankoe commented Mar 27, 2018

I ❤️ you so much for this! Just merged your changes into the gist.

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