blob: e43c21ca43b5d7ff02198109edc2bb3504397163 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# wallpaper-switcher
An Openbox (or labwc) pipe menu that lists the `.png` and `.webp` files in
`~/.wallpapers` and sets the one you pick with `swaybg`.
## Build
Needs SBCL. The only dependency is UIOP, which ships with ASDF, so Quicklisp
is not required.
make # builds ./wallpaper-switcher
make test
make install # copies it to ~/.local/bin (override with PREFIX=...)
## Menu setup
In `menu.xml`:
```xml
<menu id="wallpapers" label="Wallpapers" execute="wallpaper-switcher" />
```
Then reference `wallpapers` from your root menu and reconfigure Openbox.
Picking an item runs `wallpaper-switcher --set FILE`, which runs the
configured command and saves the path to
`$XDG_STATE_HOME/wallpaper-switcher/current` (usually
`~/.local/state/wallpaper-switcher/current`). Items call the program by its
absolute path, so it does not need to be on `PATH`.
## Restoring at login
Add this to `~/.config/labwc/autostart` (or `~/.config/openbox/autostart`):
wallpaper-switcher --restore &
It sets the saved wallpaper again with the current `command` setting. If you
pass `--config` or `--command` to the menu, pass the same options here.
## Configuration
Optional. Put it in `$XDG_CONFIG_HOME/wallpaper-switcher/config` (usually
`~/.config/wallpaper-switcher/config`):
```
# Where to look (~ and $HOME are expanded). Subdirectories become submenus;
# hidden ones (starting with .) are skipped.
directory = ~/.wallpapers
# Shell command run when an item is picked or restored. %f is the file
# (already quoted for the shell), %% is a literal %. It is run with sh -c and
# waited for, so anything long-running (like swaybg) must end with &. The
# wallpaper is only saved if the command exits with status 0.
command = pkill -x swaybg; swaybg -m fill -i %f &
# File extensions to include, matched without regard to case.
extensions = png webp
```
Command-line options override the file:
wallpaper-switcher --directory ~/Pictures/walls --command 'swaybg -m fit -i %f &'
wallpaper-switcher --config /path/to/other/config
|