From ddbfcc111f2f6f902d2c710cf89397709cc1bcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 24 May 2025 13:29:31 +0200 Subject: [PATCH 1/2] Rebase the hyprland config on the example one --- .config/hypr/hyprland.conf | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index e03cd84..c802f66 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -58,6 +58,23 @@ env = XCURSOR_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 ### ##################### @@ -87,6 +104,7 @@ general { # https://wiki.hyprland.org/Configuring/Variables/#decoration decoration { rounding = 10 + rounding_power = 2 # Change transparency of focused and unfocused windows active_opacity = 1.0 @@ -142,15 +160,12 @@ animations { # Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/ # "Smart gaps" / "No gaps when only" # uncomment all if you wish to use that. -# workspace = w[t1], gapsout:0, gapsin:0 -# workspace = w[tg1], gapsout:0, gapsin:0 +# workspace = w[tv1], gapsout:0, gapsin:0 # workspace = f[1], gapsout:0, gapsin:0 -# windowrulev2 = bordersize 0, floating:0, onworkspace:w[t1] -# windowrulev2 = rounding 0, floating:0, onworkspace:w[t1] -# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tg1] -# windowrulev2 = rounding 0, floating:0, onworkspace:w[tg1] -# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1] -# windowrulev2 = rounding 0, floating:0, onworkspace:f[1] +# windowrule = bordersize 0, floating:0, onworkspace:w[tv1] +# windowrule = rounding 0, floating:0, onworkspace:w[tv1] +# windowrule = bordersize 0, floating:0, onworkspace:f[1] +# windowrule = rounding 0, floating:0, onworkspace:f[1] # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more dwindle { From 039489d0bf7ba2da2f8ecf22abe901e63114665e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 24 May 2025 13:34:03 +0200 Subject: [PATCH 2/2] Replace the set_wallpaper bash script by the more capable wallpaper python script --- .config/hypr/hyprland.conf | 2 +- bin/set_wallpaper | 33 -------------- bin/wallpaper | 93 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 34 deletions(-) delete mode 100755 bin/set_wallpaper create mode 100755 bin/wallpaper diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index c802f66..25c38fe 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -43,7 +43,7 @@ $lock = swaylock --color=000000 --daemonize # exec-once = $terminal # exec-once = nm-applet & # exec-once = waybar & hyprpaper & firefox -exec-once = ~/.local/bin/set_wallpaper +exec-once = ~/.local/bin/wallpaper init exec-once = waybar exec-once = hyprctl keyword monitor "Unknown-1, disable" diff --git a/bin/set_wallpaper b/bin/set_wallpaper deleted file mode 100755 index 4f09ae5..0000000 --- a/bin/set_wallpaper +++ /dev/null @@ -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 diff --git a/bin/wallpaper b/bin/wallpaper new file mode 100755 index 0000000..bbcff2a --- /dev/null +++ b/bin/wallpaper @@ -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 ", 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()