diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index 25c38fe..e03cd84 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/wallpaper init +exec-once = ~/.local/bin/set_wallpaper exec-once = waybar exec-once = hyprctl keyword monitor "Unknown-1, disable" @@ -58,23 +58,6 @@ 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 ### ##################### @@ -104,7 +87,6 @@ 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 @@ -160,12 +142,15 @@ 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[tv1], gapsout:0, gapsin:0 +# workspace = w[t1], gapsout:0, gapsin:0 +# workspace = w[tg1], gapsout:0, gapsin:0 # workspace = f[1], gapsout:0, gapsin:0 -# 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] +# 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] # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more dwindle { diff --git a/bin/set_wallpaper b/bin/set_wallpaper new file mode 100755 index 0000000..4f09ae5 --- /dev/null +++ b/bin/set_wallpaper @@ -0,0 +1,33 @@ +#!/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 deleted file mode 100755 index bbcff2a..0000000 --- a/bin/wallpaper +++ /dev/null @@ -1,93 +0,0 @@ -#!/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()