Compare commits

...

2 commits

3 changed files with 117 additions and 42 deletions

View file

@ -43,7 +43,7 @@ $lock = swaylock --color=000000 --daemonize
# exec-once = $terminal # exec-once = $terminal
# exec-once = nm-applet & # exec-once = nm-applet &
# exec-once = waybar & hyprpaper & firefox # exec-once = waybar & hyprpaper & firefox
exec-once = ~/.local/bin/set_wallpaper exec-once = ~/.local/bin/wallpaper init
exec-once = waybar exec-once = waybar
exec-once = hyprctl keyword monitor "Unknown-1, disable" exec-once = hyprctl keyword monitor "Unknown-1, disable"
@ -58,6 +58,23 @@ env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24 env = HYPRCURSOR_SIZE,24
###################
### PERMISSIONS ###
###################
# See https://wiki.hyprland.org/Configuring/Permissions/
# Please note permission changes here require a Hyprland restart and are not applied on-the-fly
# for security reasons
# ecosystem {
# enforce_permissions = 1
# }
permission = /usr/(bin|local/bin)/grim, screencopy, allow
# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
# permission = /usr/(bin|local/bin)/hyprpm, plugin, allow
##################### #####################
### LOOK AND FEEL ### ### LOOK AND FEEL ###
##################### #####################
@ -87,6 +104,7 @@ general {
# https://wiki.hyprland.org/Configuring/Variables/#decoration # https://wiki.hyprland.org/Configuring/Variables/#decoration
decoration { decoration {
rounding = 10 rounding = 10
rounding_power = 2
# Change transparency of focused and unfocused windows # Change transparency of focused and unfocused windows
active_opacity = 1.0 active_opacity = 1.0
@ -142,15 +160,12 @@ animations {
# Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/ # Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only" # "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that. # uncomment all if you wish to use that.
# workspace = w[t1], gapsout:0, gapsin:0 # workspace = w[tv1], gapsout:0, gapsin:0
# workspace = w[tg1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0 # workspace = f[1], gapsout:0, gapsin:0
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[t1] # windowrule = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[t1] # windowrule = rounding 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tg1] # windowrule = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[tg1] # windowrule = rounding 0, floating:0, onworkspace:f[1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle { dwindle {

View file

@ -1,33 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
HYPRPAPER_CNF="$HOME/.config/hypr/hyprpaper.conf"
WALLPAPER_DIR="$HOME/pictures/wallpapers"
WALLPAPER_DIR_WINTER="$WALLPAPER_DIR/winter"
# Set the wallpaper directory based on the current month
case "$(date '+%m')" in
"01"|"02"|"11"|"12")
if [ -d "$WALLPAPER_DIR_WINTER" ]; then
WALLPAPER_DIR="$WALLPAPER_DIR_WINTER"
fi
;;
esac
# Generate the configuration
if [ -d "$WALLPAPER_DIR" ]; then
WALLPAPER_FILE="$(find "$WALLPAPER_DIR" -maxdepth 1 -type f \( -iname "*\.png" -o -iname "*\.jpg" -o -iname "*\.jpeg" \) -print | shuf | head -n 1)"
if [ -L "$WALLPAPER_FILE" ]; then
WALLPAPER_FILE="$(readlink -f "$WALLPAPER_FILE")"
fi
cat >"$HYPRPAPER_CNF" << EOF
preload = $WALLPAPER_FILE
wallpaper = ,$WALLPAPER_FILE
splash = false
EOF
fi
# Set the wallpaper
hyprpaper

93
bin/wallpaper Executable file
View file

@ -0,0 +1,93 @@
#!/usr/bin/env python3
from datetime import datetime
from pathlib import Path
import random
import subprocess
import sys
import os
HYPRPAPER_CNF = "~/.config/hypr/hyprpaper.conf"
WALLPAPER_DIR = "~/pictures/wallpapers"
WALLPAPER_DIR_WINTER = "~/pictures/wallpapers/winter"
WINTER_MONTHS = [
11, # November
12, # December
1, # January
2, # February
]
def get_available_wallpapers():
w_dir = (
WALLPAPER_DIR_WINTER if datetime.now().month in WINTER_MONTHS else WALLPAPER_DIR
)
w_dir = Path(w_dir).expanduser()
wallpapers = []
for f in w_dir.iterdir():
if f.is_file(follow_symlinks=False):
wallpapers.append(f)
if f.is_symlink():
wallpapers.append(f.resolve())
return [str(p) for p in wallpapers]
def update_config():
wallpapers = get_available_wallpapers()
config_path = Path(HYPRPAPER_CNF).expanduser()
with open(config_path, "w") as f:
current_wallpaper = random.choice(wallpapers)
for w_path in wallpapers:
print(f"preload = {w_path}", file=f)
print(f"wallpaper = ,{current_wallpaper}", file=f)
print("splash = false", file=f)
def cmd_init():
update_config()
subprocess.run(["killall", "hyprpaper"])
subprocess.Popen(["hyprpaper"])
def cmd_next_wallpaper():
wallpapers = []
config_path = Path(HYPRPAPER_CNF).expanduser()
with open(config_path, "r") as f:
for line in f:
if line.startswith("preload = "):
w_path = Path(line[10:].strip("\n"))
if w_path.is_file(follow_symlinks=False):
wallpapers.append(str(w_path))
new_wallpaper = random.choice(wallpapers)
subprocess.run(["hyprctl", "hyprpaper", "wallpaper", f",{new_wallpaper}"])
def usage():
print("Usage:", file=sys.stderr)
print(" wallpaper <command>", file=sys.stderr)
print("", file=sys.stderr)
print("Available commands:", file=sys.stderr)
print(" init (re)start the daemon", file=sys.stderr)
print(" change change the wallpaper", file=sys.stderr)
print(" next alias for change", file=sys.stderr)
sys.exit(1)
def main():
if len(sys.argv) != 2:
usage()
cmd = sys.argv[1]
commands = {
# (re)start the daemon
"init": cmd_init,
# change the wallpaper
"change": cmd_next_wallpaper,
"next": cmd_next_wallpaper,
}
if cmd not in commands:
usage()
commands[cmd]()
if __name__ == "__main__":
main()