Compare commits

...

2 commits

Author SHA1 Message Date
795e6941f8
todos 2024-10-20 09:37:38 -05:00
33e47efe43
add swww implementation for random wallpapers 2024-10-20 09:36:46 -05:00
5 changed files with 64 additions and 6 deletions

View file

@ -17,6 +17,7 @@ type
id*: int
Monitor = object
activeWorkspace*: ActiveWorkspace
name: string
id*: int

View file

@ -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
]#

View file

@ -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
View 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

View file

@ -2,7 +2,8 @@
- [ ] include in class the 'other' active monitor?
- [ ] switch to usu once parser is stable again
- [ ] make swww powered wallpaper cycler
- [x] make swww powered wallpaper cycler
- [ ] add support for monitor orientation?
<!-- generated with <3 by daylinmorgan/todo -->