From ad890cc43fca4d0ce8668963eeb9ac56caab241a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Mon, 21 Dec 2020 18:32:41 +0100 Subject: [PATCH] Set wallpaper in sway --- .config/sway/config | 4 +++- .xprofile | 2 +- bin/set_wallpaper | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 bin/set_wallpaper diff --git a/.config/sway/config b/.config/sway/config index d91a6d8..d4e4ef6 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -22,7 +22,9 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec ### Output configuration # # Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/) -output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill +# output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill +exec_always set_wallpaper sway + # # Example configuration: # diff --git a/.xprofile b/.xprofile index cea2ccf..a8591dd 100644 --- a/.xprofile +++ b/.xprofile @@ -7,4 +7,4 @@ hash xcompmgr 2>/dev/null && xcompmgr & hash xscreensaver 2>/dev/null && xscreensaver -no-splash & hash gpg-agent 2>/dev/null && eval $(gpg-agent --daemon --enable-ssh-support) -hash feh 2>/dev/null && feh --bg-scale "$(find 'pictures/wallpapers/enabled/' -type l -print | shuf | head -n 1)" +hash set_wallpaper 2>/dev/null && set_wallpaper feh diff --git a/bin/set_wallpaper b/bin/set_wallpaper new file mode 100755 index 0000000..0066664 --- /dev/null +++ b/bin/set_wallpaper @@ -0,0 +1,16 @@ +#!/bin/sh + +set -euo pipefail +IFS=$'\n\t' + +WALLPAPER_DIRECTORY="$HOME/pictures/wallpapers/enabled" +WALLPAPER_FILE="$(find "$WALLPAPER_DIRECTORY" -type l -print | shuf | head -n 1)" + +case "$1" in + sway) + swaymsg --quiet output "*" bg "$WALLPAPER_FILE" fill + ;; + *) + hash feh 2>/dev/null && feh --bg-scale "$WALLPAPER_FILE" + ;; +esac