better swaybg management in wl

This commit is contained in:
Paul Wilde 2024-03-21 10:16:29 +00:00
parent ade0f07359
commit c96d39f05d
2 changed files with 14 additions and 3 deletions

View file

@ -65,12 +65,21 @@ proc getImageFromDir(): string =
notify.send("Found : ", img_file)
return img_file
proc getCurrSwayBGPID(): string =
let pid = execCmdEx("pgrep swaybg")
return pid.output
proc killCurrSwayBGPID(pid: string) =
discard execCmd("kill " & pid)
proc setImage(img: string) =
notify.send("Setting Background to:",img)
if isWayland():
let swaybg = "killall swaybg; swaybg -m fill -i " & img.escape & " &"
echo swaybg
let pid = getCurrSwayBGPID()
let swaybg = "swaybg -m fill -i " & img.escape & " &"
discard execCmd(swaybg)
killCurrSwayBGPID(pid)
else:
let feh = "feh --bg-fill " & img.escape
discard execCmdEx(feh)
@ -78,8 +87,10 @@ proc setImage(img: string) =
proc setLast() =
notify.send("Setting Background to Last", LAST)
if isWayland():
let pid = getCurrSwayBGPID()
let swaybg = "killall swaybg; swaybg -m fill -i " & LAST.escape & " &"
discard execCmd(swaybg)
killCurrSwayBGPID(pid)
else:
let feh = "feh --bg-fill " & LAST.escape
discard execCmdEx(feh)

View file

@ -1,6 +1,6 @@
# Package
version = "2.0.5"
version = "2.0.6"
author = "Paul Wilde"
description = "A set of informational tools"
license = "AGPL-3.0-or-later"