From e0ec9175f47df511805df6990910523a6562974e Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 19 Feb 2026 23:59:51 -0800 Subject: [PATCH] feat(wm): add rofi wallpaper launcher and keybindings --- dotfiles/config/hypr/hyprland.conf | 1 + dotfiles/config/xmonad/xmonad | 2 +- dotfiles/config/xmonad/xmonad-contrib | 2 +- dotfiles/config/xmonad/xmonad.hs | 1 + dotfiles/lib/bin/rofi_wallpaper.sh | 96 +++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100755 dotfiles/lib/bin/rofi_wallpaper.sh diff --git a/dotfiles/config/hypr/hyprland.conf b/dotfiles/config/hypr/hyprland.conf index b71230b8..9f0cb586 100644 --- a/dotfiles/config/hypr/hyprland.conf +++ b/dotfiles/config/hypr/hyprland.conf @@ -523,6 +523,7 @@ bind = $hyper, slash, exec, toggle_taffybar bind = $hyper, 9, exec, start_synergy.sh bind = $hyper, I, exec, rofi_select_input.hs bind = $hyper, O, exec, rofi_paswitch +bind = $hyper, W, exec, rofi_wallpaper.sh bind = $hyper, Y, exec, rofi_agentic_skill # Reload config diff --git a/dotfiles/config/xmonad/xmonad b/dotfiles/config/xmonad/xmonad index a613c5cb..8113e0fe 160000 --- a/dotfiles/config/xmonad/xmonad +++ b/dotfiles/config/xmonad/xmonad @@ -1 +1 @@ -Subproject commit a613c5cb730f07dda08dd39ff7a082ba30848f3a +Subproject commit 8113e0fe5566dd8841b7de664c364a26cef385fb diff --git a/dotfiles/config/xmonad/xmonad-contrib b/dotfiles/config/xmonad/xmonad-contrib index b71f9e4c..1a8da468 160000 --- a/dotfiles/config/xmonad/xmonad-contrib +++ b/dotfiles/config/xmonad/xmonad-contrib @@ -1 +1 @@ -Subproject commit b71f9e4c9dfdbb71c1b55f30edb0da524b0ed251 +Subproject commit 1a8da46855ca83e11cfb31cbbaed980ed7a8dfcc diff --git a/dotfiles/config/xmonad/xmonad.hs b/dotfiles/config/xmonad/xmonad.hs index d0155882..c53577dc 100644 --- a/dotfiles/config/xmonad/xmonad.hs +++ b/dotfiles/config/xmonad/xmonad.hs @@ -1100,6 +1100,7 @@ addKeys conf@XConfig { modMask = modm } = , ((hyper, xK_space), spawn "skippy-xd") , ((hyper, xK_i), spawn "rofi_select_input.hs") , ((hyper, xK_o), spawn "rofi_paswitch") + , ((hyper, xK_w), spawn "rofi_wallpaper.sh") , ((hyper, xK_y), spawn "rofi_agentic_skill") , ((modm, xK_e), spawn "emacsclient --eval '(emacs-everywhere)'") diff --git a/dotfiles/lib/bin/rofi_wallpaper.sh b/dotfiles/lib/bin/rofi_wallpaper.sh new file mode 100755 index 00000000..ec99769d --- /dev/null +++ b/dotfiles/lib/bin/rofi_wallpaper.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -euo pipefail + +wallpaper_dir="${WALLPAPER_DIR:-/var/lib/syncthing/sync/Wallpaper}" + +notify() { + if command -v notify-send >/dev/null 2>&1; then + notify-send "Wallpaper" "$1" + else + printf '%s\n' "$1" >&2 + fi +} + +if ! command -v rofi >/dev/null 2>&1; then + notify "rofi is not installed" + exit 1 +fi + +if [ ! -d "$wallpaper_dir" ]; then + notify "Wallpaper directory not found: $wallpaper_dir" + exit 1 +fi + +mapfile -d '' wallpapers < <( + find "$wallpaper_dir" -type f \ + \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.webp' \) \ + -print0 | sort -z +) + +if [ "${#wallpapers[@]}" -eq 0 ]; then + notify "No wallpapers found in $wallpaper_dir" + exit 1 +fi + +selection=$( + for wallpaper in "${wallpapers[@]}"; do + printf '%s\n' "${wallpaper#"$wallpaper_dir"/}" + done | rofi -dmenu -i -p "Wallpaper" +) + +if [ -z "${selection:-}" ]; then + exit 0 +fi + +selected_wallpaper="$wallpaper_dir/$selection" +if [ ! -f "$selected_wallpaper" ]; then + notify "Wallpaper not found: $selected_wallpaper" + exit 1 +fi + +apply_hyprpaper() { + local monitor + + if ! command -v hyprctl >/dev/null 2>&1; then + return 1 + fi + + hyprctl hyprpaper preload "$selected_wallpaper" >/dev/null 2>&1 || true + + if ! hyprctl monitors >/dev/null 2>&1; then + return 1 + fi + + while read -r monitor; do + [ -z "$monitor" ] && continue + hyprctl hyprpaper wallpaper "$monitor,$selected_wallpaper" >/dev/null 2>&1 || true + done < <(hyprctl monitors | awk '/^Monitor / { print $2 }') + + return 0 +} + +apply_x11() { + if ! command -v feh >/dev/null 2>&1; then + return 1 + fi + + feh --no-fehbg --bg-fill "$selected_wallpaper" +} + +if [ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ] || [ "${XDG_CURRENT_DESKTOP:-}" = "Hyprland" ]; then + if apply_hyprpaper; then + notify "Applied: ${selection}" + exit 0 + fi +fi + +if [ -n "${DISPLAY:-}" ]; then + if apply_x11; then + notify "Applied: ${selection}" + exit 0 + fi +fi + +notify "Unable to determine wallpaper backend for this session" +exit 1