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
|
id*: int
|
||||||
Monitor = object
|
Monitor = object
|
||||||
activeWorkspace*: ActiveWorkspace
|
activeWorkspace*: ActiveWorkspace
|
||||||
|
name: string
|
||||||
id*: int
|
id*: int
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
## hyprman, the hyprland companion
|
## hyprman, the hyprland companion
|
||||||
|
|
||||||
import std/[osproc, strformat]
|
import std/[os, osproc, strformat]
|
||||||
import hwylterm/cligen, cligen
|
import hwylterm/cligen, cligen
|
||||||
import ./[mako,hyprland, lib]# state]
|
import ./[
|
||||||
|
hyprland,
|
||||||
|
lib,
|
||||||
|
mako,
|
||||||
|
swww
|
||||||
|
]
|
||||||
|
|
||||||
hwylCli(clCfg)
|
hwylCli(clCfg)
|
||||||
|
|
||||||
|
@ -18,6 +23,10 @@ proc watch() =
|
||||||
## watch hyprland events for eww class changes
|
## watch hyprland events for eww class changes
|
||||||
watchHyprland()
|
watchHyprland()
|
||||||
|
|
||||||
|
proc swww() =
|
||||||
|
## set swww to cycle through wallpapers
|
||||||
|
runSwww()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
const
|
const
|
||||||
config = //{"config": "path/to/config"}
|
config = //{"config": "path/to/config"}
|
||||||
|
@ -27,7 +36,19 @@ when isMainModule:
|
||||||
"reverse": "swap notification order"
|
"reverse": "swap notification order"
|
||||||
}
|
}
|
||||||
dispatchMulti(
|
dispatchMulti(
|
||||||
[makoCmd, cmdName = "mako", usage = clCfg.use, help = makoHelp],
|
[makoCmd, usage = clCfg.use, help = makoHelp, cmdName = "mako",],
|
||||||
[start , usage = clCfg.use],
|
[start , usage = clCfg.use],
|
||||||
[watch, 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
|
type
|
||||||
Icons = Table[string, string]
|
Icons = Table[string, string]
|
||||||
Config = object # config vs icons?
|
Config = object # config vs icons?
|
||||||
|
wallpapers* {.defaultVal: ""}: string
|
||||||
classes*: Icons
|
classes*: Icons
|
||||||
`no-client`*: string
|
`no-client`*: string
|
||||||
`default-icon`*: string
|
`default-icon`*: string
|
||||||
|
@ -19,6 +20,7 @@ proc loadConfig*(): Config =
|
||||||
if fileExists(configPath):
|
if fileExists(configPath):
|
||||||
var s = newFileStream(configPath)
|
var s = newFileStream(configPath)
|
||||||
load(s, result)
|
load(s, result)
|
||||||
|
result.wallpapers = expandTilde(result.wallpapers)
|
||||||
|
|
||||||
func pickIcon*(
|
func pickIcon*(
|
||||||
c: Config,
|
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