From 6e31377f8a7baa128089a80e1c1d285807fe6ec3 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Wed, 20 Mar 2024 21:28:55 +0000 Subject: [PATCH] made wallpapurr wayland compatible --- src/common/display.nim | 10 ++++++++++ src/util/wallpapurr.nim | 18 ++++++++++++++---- wm_tools.nimble | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/common/display.nim diff --git a/src/common/display.nim b/src/common/display.nim new file mode 100644 index 0000000..9d58792 --- /dev/null +++ b/src/common/display.nim @@ -0,0 +1,10 @@ +import std/envvars + +const XDG_SESSION_TYPE = "XDG_SESSION_TYPE" +const WAYLAND = "wayland" + +proc isWayland*(): bool = + if existsEnv(XDG_SESSION_TYPE) and getEnv(XDG_SESSION_TYPE) == WAYLAND: + echo "WAYLAND!" + return true + return false diff --git a/src/util/wallpapurr.nim b/src/util/wallpapurr.nim index f11fc16..17629b4 100644 --- a/src/util/wallpapurr.nim +++ b/src/util/wallpapurr.nim @@ -8,6 +8,7 @@ import httpclient import ../common import ../common/http +import ../common/display import ../parser import ../output import ../notify @@ -66,13 +67,22 @@ proc getImageFromDir(): string = proc setImage(img: string) = notify.send("Setting Background to:",img) - let feh = "feh --bg-fill " & img.escape - discard execCmdEx(feh) + if isWayland(): + let swaybg = "killall swaybg; swaybg -m fill -i " & img.escape & " &" + echo swaybg + discard execCmd(swaybg) + else: + let feh = "feh --bg-fill " & img.escape + discard execCmdEx(feh) proc setLast() = notify.send("Setting Background to Last", LAST) - let feh = "feh --bg-fill " & LAST.escape - discard execCmdEx(feh) + if isWayland(): + let swaybg = "killall swaybg; swaybg -m fill -i " & LAST.escape & " &" + discard execCmd(swaybg) + else: + let feh = "feh --bg-fill " & LAST.escape + discard execCmdEx(feh) proc getDesign(): Info = var data = newInfo("Wallpapurr") diff --git a/wm_tools.nimble b/wm_tools.nimble index 91d697e..5c9f840 100644 --- a/wm_tools.nimble +++ b/wm_tools.nimble @@ -1,6 +1,6 @@ # Package -version = "2.0.1" +version = "2.0.5" author = "Paul Wilde" description = "A set of informational tools" license = "AGPL-3.0-or-later"