add swww implementation for random wallpapers
This commit is contained in:
parent
1561acdb5f
commit
33e47efe43
4 changed files with 62 additions and 5 deletions
|
@ -17,6 +17,7 @@ type
|
|||
id*: int
|
||||
Monitor = object
|
||||
activeWorkspace*: ActiveWorkspace
|
||||
name: string
|
||||
id*: int
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
## hyprman, the hyprland companion
|
||||
|
||||
import std/[osproc, strformat]
|
||||
import std/[os, osproc, strformat]
|
||||
import hwylterm/cligen, cligen
|
||||
import ./[mako,hyprland, lib]# state]
|
||||
import ./[
|
||||
hyprland,
|
||||
lib,
|
||||
mako,
|
||||
swww
|
||||
]
|
||||
|
||||
hwylCli(clCfg)
|
||||
|
||||
|
@ -18,6 +23,10 @@ proc watch() =
|
|||
## watch hyprland events for eww class changes
|
||||
watchHyprland()
|
||||
|
||||
proc swww() =
|
||||
## set swww to cycle through wallpapers
|
||||
runSwww()
|
||||
|
||||
when isMainModule:
|
||||
const
|
||||
config = //{"config": "path/to/config"}
|
||||
|
@ -27,7 +36,19 @@ when isMainModule:
|
|||
"reverse": "swap notification order"
|
||||
}
|
||||
dispatchMulti(
|
||||
[makoCmd, cmdName = "mako", usage = clCfg.use, help = makoHelp],
|
||||
[start, usage = clCfg.use],
|
||||
[watch, usage = clCfg.use]
|
||||
[makoCmd, usage = clCfg.use, help = makoHelp, cmdName = "mako",],
|
||||
[start , usage = clCfg.use],
|
||||
[watch , usage = clCfg.use],
|
||||
[swww , usage = clCfg.use],
|
||||
)
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#[
|
||||
DIR=./woodblock-cherry-blossom/
|
||||
while : ; do
|
||||
for file in $(find $DIR -type f -name '*.png');do
|
||||
swww img "$file" --transition-type wave
|
||||
sleep 3600
|
||||
done
|
||||
done
|
||||
]#
|
||||
|
|
|
@ -10,6 +10,7 @@ proc notify*(message: string) =
|
|||
type
|
||||
Icons = Table[string, string]
|
||||
Config = object # config vs icons?
|
||||
wallpapers* {.defaultVal: ""}: string
|
||||
classes*: Icons
|
||||
`no-client`*: string
|
||||
`default-icon`*: string
|
||||
|
@ -19,6 +20,7 @@ proc loadConfig*(): Config =
|
|||
if fileExists(configPath):
|
||||
var s = newFileStream(configPath)
|
||||
load(s, result)
|
||||
result.wallpapers = expandTilde(result.wallpapers)
|
||||
|
||||
func pickIcon*(
|
||||
c: Config,
|
||||
|
|
33
src/swww.nim
Normal file
33
src/swww.nim
Normal file
|
@ -0,0 +1,33 @@
|
|||
import std/[os, osproc, strformat, strutils, random]
|
||||
import ./lib
|
||||
|
||||
proc loadGallery(): seq[string] =
|
||||
for path in walkDirRec(
|
||||
config.wallpapers, yieldFilter = {pcFile, pcLinkToFile}
|
||||
):
|
||||
let (_,_, ext) = splitFile(path)
|
||||
if ext in [".png", ".jpeg"]:
|
||||
result.add path
|
||||
|
||||
proc swwwMonitors(): seq[string] =
|
||||
let (output, code) = execCmdEx("swww query")
|
||||
if code != 0: notify "swww failed"
|
||||
for line in output.strip().splitLines():
|
||||
result.add line.split(':', 1)[0]
|
||||
|
||||
proc setImg(path: string, output: string) =
|
||||
let code =
|
||||
execCmd(fmt"swww img --transition-type fade --outputs {output} {path}")
|
||||
if code != 0: notify "swww failed"
|
||||
|
||||
proc runSwww*() =
|
||||
if config.wallpapers == "": quit(0)
|
||||
if not dirExists(config.wallpapers):
|
||||
notify(fmt"{config.wallpapers} directory does not exist")
|
||||
quit(1)
|
||||
let gallery = loadGallery()
|
||||
while true:
|
||||
for monitor in swwwMonitors():
|
||||
setImg(gallery.sample(), monitor)
|
||||
sleep 1000 * 60 * 30
|
||||
|
Loading…
Reference in a new issue