add infra to trigger swww
This commit is contained in:
parent
8fa101f0e2
commit
c93f726dd6
3 changed files with 16 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
import std/[os, strformat, strutils, streams, tables, net, sugar]
|
import std/[os, strformat, strutils, streams, tables, net, sugar]
|
||||||
import ./lib
|
import ./[lib, swww]
|
||||||
export tables
|
export tables
|
||||||
import yaml, jsony
|
import yaml, jsony
|
||||||
|
|
||||||
|
@ -124,9 +124,10 @@ proc handleHyprEvent(event: string) =
|
||||||
s = event.split(">>", 1)
|
s = event.split(">>", 1)
|
||||||
event = s[0]
|
event = s[0]
|
||||||
|
|
||||||
if event == "monitoraddedv2":
|
if event in ["monitoraddedv2", "monitorremoved"]:
|
||||||
# TODO: open as many bars as necessary depending on num monitors
|
# TODO: open as many bars as necessary depending on num monitors
|
||||||
notify("monitor added")
|
notify("monitor added")
|
||||||
|
oneShotSwww()
|
||||||
|
|
||||||
if event in redrawEvents:
|
if event in redrawEvents:
|
||||||
writeEwwClasses()
|
writeEwwClasses()
|
||||||
|
|
|
@ -25,7 +25,7 @@ proc watch() =
|
||||||
|
|
||||||
proc swww() =
|
proc swww() =
|
||||||
## set swww to cycle through wallpapers
|
## set swww to cycle through wallpapers
|
||||||
runSwww()
|
persistentSwww()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
const
|
const
|
||||||
|
|
14
src/swww.nim
14
src/swww.nim
|
@ -1,6 +1,8 @@
|
||||||
import std/[os, osproc, strformat, strutils, random]
|
import std/[os, osproc, strformat, strutils, random]
|
||||||
import ./lib
|
import ./lib
|
||||||
|
|
||||||
|
const oneMinute = 1000 * 60
|
||||||
|
|
||||||
proc loadGallery(): seq[string] =
|
proc loadGallery(): seq[string] =
|
||||||
for path in walkDirRec(
|
for path in walkDirRec(
|
||||||
config.wallpapers, yieldFilter = {pcFile, pcLinkToFile}
|
config.wallpapers, yieldFilter = {pcFile, pcLinkToFile}
|
||||||
|
@ -20,9 +22,17 @@ proc setImg(path: string, output: string) =
|
||||||
execCmd(fmt"swww img --transition-type fade --outputs {output} {path}")
|
execCmd(fmt"swww img --transition-type fade --outputs {output} {path}")
|
||||||
if code != 0: notify "swww failed"
|
if code != 0: notify "swww failed"
|
||||||
|
|
||||||
const oneMinute = 1000 * 60
|
proc oneShotSwww*() =
|
||||||
|
if config.wallpapers == "": return
|
||||||
|
if not dirExists(config.wallpapers):
|
||||||
|
notify(fmt"{config.wallpapers} directory does not exist")
|
||||||
|
quit(1)
|
||||||
|
let gallery = loadGallery()
|
||||||
|
for monitor in swwwMonitors():
|
||||||
|
setImg(gallery.sample(), monitor)
|
||||||
|
|
||||||
proc runSwww*() =
|
|
||||||
|
proc persistentSwww*() =
|
||||||
if config.wallpapers == "": quit(0)
|
if config.wallpapers == "": quit(0)
|
||||||
if not dirExists(config.wallpapers):
|
if not dirExists(config.wallpapers):
|
||||||
notify(fmt"{config.wallpapers} directory does not exist")
|
notify(fmt"{config.wallpapers} directory does not exist")
|
||||||
|
|
Loading…
Reference in a new issue