From 18021a3eb5f9792755eed273631771cb3f45a2b5 Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Sat, 26 Jun 2021 01:15:49 +0200 Subject: [PATCH] =?UTF-8?q?FOND=20d'=C3=A9cran:=20adaptation=20pour=20Sway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/sway/config.d/90-programmes.conf | 3 +++ bin/random_wallpaper | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.config/sway/config.d/90-programmes.conf b/.config/sway/config.d/90-programmes.conf index f7cceba..21372e0 100644 --- a/.config/sway/config.d/90-programmes.conf +++ b/.config/sway/config.d/90-programmes.conf @@ -3,3 +3,6 @@ exec wlsunset -l 48.5680685 -L 7.7709942 # Notifications de bureau exec dunst + +# Fond d'écran aléatoire +exec_always "kill -9 `ps aux | grep random_wallpaper |grep -v 'grep'| awk '{print $2}'`; random_wallpaper &" diff --git a/bin/random_wallpaper b/bin/random_wallpaper index 8772d5b..1fc68b6 100755 --- a/bin/random_wallpaper +++ b/bin/random_wallpaper @@ -6,11 +6,19 @@ directory="$HOME/wallpapers" minutes=15 +PROGRAM=`which feh` # Some tests -if [ -z "`which feh`" ]; then +if [[ "$XDG_SESSION_TYPE" -eq "wayland" ]]; then + PROGRAM=`which swaymsg` + if [ -z "${PROGRAM}" ]; then + echo "This script needs the swaymsg program." + exit 1 + fi + wayland=1 +elif [ -z "${PROGRAM}" ]; then echo "This script needs the feh program. Install it." -i exit 1 + exit 1 fi if [ -d '$directory' ]; then @@ -40,7 +48,11 @@ while true; do # Change background file="${array_files["$NUMBER"]}" - feh --bg-fill "$directory/$file" + if [[ -n wayland ]]; then + $PROGRAM output "*" bg "$directory/$file" fill + else + feh --bg-fill "$directory/$file" + fi # Wait some times sleep $seconds