Compare commits

...

4 Commits

Author SHA1 Message Date
32c81e8df8 Update README.md 2023-10-26 06:01:33 -04:00
33b1df8b6b small refactor + fixed dbus command path 2022-07-15 18:30:47 +10:00
e4d8bccdab Added plasma wallpaperengine 2022-07-15 17:13:48 +10:00
fc271e6496 Added config stuffs 2022-07-15 08:55:47 +10:00
3 changed files with 68 additions and 21 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vscode/
Pipfile
Pipfile.lock
.notes/

View File

@ -12,3 +12,19 @@ sudo mv -v wallpaperctl.py /usr/bin/wallpaperctl
```
## Config options
### General
```ini
- WALLHAVEN_API_KEY=asdfg
- X_SERVER=:0
- WALLPAPER_ENGINE=feh
- ULTRA_WALL_DIR=~/Pictures/wallpaper-ultra
- HOR_WALL_DIR=~/Pictures/wallpaper-hor
- VERT_WALL_DIR=~/Pictures/wallpaper-vert
[Monitors]
1=ultrawide
2=vertical
3=horizontal
```

View File

@ -3,17 +3,43 @@
import configparser
import os
import random
from pathlib import Path
import sys
import subprocess
from pathlib import Path
def find_all_images(path):
IMAGE_TYPES = ['jpg', 'png', 'webp', 'jpeg']
if WALLPAPER_ENGINE == 'plasma':
IMAGE_TYPES.remove("webp")
images = []
for image_type in IMAGE_TYPES:
[images.append(image) for image in path.glob(f'**/*.{image_type}')]
return images
def handle_feh(wallpapers):
cmd = "/usr/bin/feh --no-fehbg --bg-fill "
for wallpaper in wallpapers:
cmd += str(f"{wallpaper} ")
subprocess.call(cmd, shell=True)
def handle_plasma(wallpapers):
fuckingGarbageJS = """
var allDesktops = desktops();
"""
for wallpaper in wallpapers:
wallpaperIndex = wallpapers.index(wallpaper)
fuckingGarbageJS += f"""allDesktops[{wallpaperIndex}].wallpaperPlugin = "org.kde.image";
allDesktops[{wallpaperIndex}].currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
allDesktops[{wallpaperIndex}].writeConfig("Image", "file://{wallpaper}");
"""
cmd = f"/usr/bin/qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '{fuckingGarbageJS}'"
subprocess.call(cmd, shell=True)
def handle_gnome(wallpapers):
raise NotImplementedError
conf_file = f"{os.environ['HOME']}/.config/wallpaperctl/wallpaperctl.ini"
# Initialize config file
@ -54,13 +80,17 @@ for mon in monitors:
case _:
print(monitors[mon])
print(wallpapers)
cmd = "/usr/bin/feh --no-fehbg --bg-fill "
match WALLPAPER_ENGINE:
case 'feh':
handle_feh(wallpapers)
for wallpaper in wallpapers:
cmd += str(f"{wallpaper} ")
case 'plasma':
handle_plasma(wallpapers)
subprocess.call(cmd, shell=True)
case 'gnome':
handle_gnome(wallpapers)
# subprocess.call("ls -alh",shell=True)
case _:
print(f"Wallpaper engine {WALLPAPER_ENGINE} is not supported")
sys.exit()