eww widgets and theme cycle with waybar button
This commit is contained in:
131
hypr/2d-nav.sh
Normal file
131
hypr/2d-nav.sh
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
# ~/.config/hypr/2d-nav.sh
|
||||
# 2D workspace navigation for Hyprland
|
||||
# Workspaces are named "X" (base row) or "X-Y" (sub-row, Y >= 1)
|
||||
# Usage: 2d-nav.sh [left|right|up|down|move-left|move-right|move-up|move-down]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ACTION="${1:-}"
|
||||
|
||||
# --- Parse current workspace ---
|
||||
# Returns e.g. "3" or "3-2"
|
||||
get_current_ws() {
|
||||
hyprctl activeworkspace -j | jq -r '.name'
|
||||
}
|
||||
|
||||
# Split "X-Y" into X and Y parts
|
||||
parse_ws() {
|
||||
local name="$1"
|
||||
if [[ "$name" =~ ^([0-9]+)-([0-9]+)$ ]]; then
|
||||
echo "${BASH_REMATCH[1]} ${BASH_REMATCH[2]}"
|
||||
elif [[ "$name" =~ ^([0-9]+)$ ]]; then
|
||||
echo "${BASH_REMATCH[1]} 0"
|
||||
else
|
||||
# Named/special workspace we don't manage — bail
|
||||
echo "0 0"
|
||||
fi
|
||||
}
|
||||
|
||||
make_ws_name() {
|
||||
local x="$1" y="$2"
|
||||
if [[ "$y" -eq 0 ]]; then
|
||||
echo "$x"
|
||||
else
|
||||
echo "${x}-${y}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if a named workspace currently exists (has at least one window OR is active)
|
||||
ws_exists() {
|
||||
local name="$1"
|
||||
hyprctl workspaces -j | jq -e --arg n "$name" '.[] | select(.name == $n)' > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Navigate to workspace (creates it on demand if going up; smart-back if going down)
|
||||
go_to_ws() {
|
||||
local name="$1"
|
||||
hyprctl dispatch workspace "name:${name}"
|
||||
}
|
||||
|
||||
move_window_to_ws() {
|
||||
local name="$1"
|
||||
hyprctl dispatch movetoworkspace "name:${name}"
|
||||
}
|
||||
|
||||
# --- Main logic ---
|
||||
current=$(get_current_ws)
|
||||
read -r cx cy <<< "$(parse_ws "$current")"
|
||||
|
||||
# Min/max for X axis (your config has 1-5 on DP-2, 6-10 on HDMI-A-1)
|
||||
# But for 2D nav we treat X as free-range 1..10
|
||||
X_MIN=1
|
||||
X_MAX=10
|
||||
Y_MIN=0
|
||||
Y_MAX=9 # Reasonable cap for sub-workspaces
|
||||
|
||||
case "$ACTION" in
|
||||
right)
|
||||
nx=$(( cx < X_MAX ? cx + 1 : cx ))
|
||||
# When moving right, land on base row of target X (Y=0)
|
||||
target=$(make_ws_name "$nx" 0)
|
||||
go_to_ws "$target"
|
||||
;;
|
||||
left)
|
||||
nx=$(( cx > X_MIN ? cx - 1 : cx ))
|
||||
target=$(make_ws_name "$nx" 0)
|
||||
go_to_ws "$target"
|
||||
;;
|
||||
up)
|
||||
ny=$(( cy < Y_MAX ? cy + 1 : cy ))
|
||||
target=$(make_ws_name "$cx" "$ny")
|
||||
go_to_ws "$target"
|
||||
;;
|
||||
down)
|
||||
if [[ "$cy" -gt 0 ]]; then
|
||||
ny=$(( cy - 1 ))
|
||||
# If the workspace below doesn't exist, fall back to base (Y=0), not Y=(cy-1)
|
||||
target=$(make_ws_name "$cx" "$ny")
|
||||
if [[ "$ny" -gt 0 ]] && ! ws_exists "$target"; then
|
||||
target=$(make_ws_name "$cx" 0)
|
||||
fi
|
||||
else
|
||||
target=$(make_ws_name "$cx" 0)
|
||||
fi
|
||||
go_to_ws "$target"
|
||||
;;
|
||||
|
||||
# --- Move window variants ---
|
||||
move-right)
|
||||
nx=$(( cx < X_MAX ? cx + 1 : cx ))
|
||||
target=$(make_ws_name "$nx" 0)
|
||||
move_window_to_ws "$target"
|
||||
;;
|
||||
move-left)
|
||||
nx=$(( cx > X_MIN ? cx - 1 : cx ))
|
||||
target=$(make_ws_name "$nx" 0)
|
||||
move_window_to_ws "$target"
|
||||
;;
|
||||
move-up)
|
||||
ny=$(( cy < Y_MAX ? cy + 1 : cy ))
|
||||
target=$(make_ws_name "$cx" "$ny")
|
||||
move_window_to_ws "$target"
|
||||
;;
|
||||
move-down)
|
||||
if [[ "$cy" -gt 0 ]]; then
|
||||
ny=$(( cy - 1 ))
|
||||
target=$(make_ws_name "$cx" "$ny")
|
||||
if [[ "$ny" -gt 0 ]] && ! ws_exists "$target"; then
|
||||
target=$(make_ws_name "$cx" 0)
|
||||
fi
|
||||
else
|
||||
target=$(make_ws_name "$cx" 0)
|
||||
fi
|
||||
move_window_to_ws "$target"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 [left|right|up|down|move-left|move-right|move-up|move-down]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
21
hypr/2d-workspaces.sh
Normal file
21
hypr/2d-workspaces.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# ~/.config/hypr/2d-workspaces.sh
|
||||
# Outputs current 2D position as Waybar JSON: "3" or "3.2"
|
||||
|
||||
current=$(hyprctl activeworkspace -j | jq -r '.name')
|
||||
|
||||
if [[ "$current" =~ ^([0-9]+)-([0-9]+)$ ]]; then
|
||||
cx="${BASH_REMATCH[1]}"
|
||||
cy="${BASH_REMATCH[2]}"
|
||||
label="${cx}.${cy}"
|
||||
class="sub"
|
||||
elif [[ "$current" =~ ^([0-9]+)$ ]]; then
|
||||
cx="${BASH_REMATCH[1]}"
|
||||
label="${cx}"
|
||||
class="base"
|
||||
else
|
||||
label="?"
|
||||
class="unknown"
|
||||
fi
|
||||
|
||||
printf '{"text": "%s", "class": "%s"}\n' "$label" "$class"
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
# ~/.config/hypr/autostart.sh
|
||||
# Launches apps and moves them to the correct workspace once their window appears.
|
||||
# Use in hyprland.conf:
|
||||
# exec-once = ~/.config/hypr/autostart.sh
|
||||
|
||||
# ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
# Wait for a window matching a class/title regex, then move it to a workspace.
|
||||
# Usage: launch_on <workspace> <class_regex> <command>
|
||||
launch_on() {
|
||||
local ws="$1"
|
||||
local class="$2"
|
||||
shift 2
|
||||
local cmd=("$@")
|
||||
|
||||
# Launch the app in the background
|
||||
"${cmd[@]}" &
|
||||
|
||||
# Poll until the window appears, then move it
|
||||
for _ in $(seq 1 30); do
|
||||
sleep 1
|
||||
local addr
|
||||
addr=$(hyprctl clients -j \
|
||||
| grep -i "\"class\": \"$class\"" \
|
||||
| head -1)
|
||||
if [[ -n "$addr" ]]; then
|
||||
hyprctl dispatch movetoworkspacesilent "$ws,class:^(${class})$"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ── app definitions ───────────────────────────────────────────────────────────
|
||||
# launch_on <workspace> <window class> <command ...>
|
||||
|
||||
launch_on 1 firefox firefox
|
||||
launch_on 2 code code
|
||||
launch_on 3 kitty kitty
|
||||
launch_on 4 vesktop vesktop
|
||||
launch_on 5 steam steam
|
||||
launch_on 6 spotify spotify
|
||||
59
hypr/depencies-check.sh
Normal file
59
hypr/depencies-check.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ─────────────────────────────────────────
|
||||
# Dependency Checker
|
||||
# ─────────────────────────────────────────
|
||||
|
||||
DEPS=(
|
||||
eww
|
||||
steam
|
||||
code
|
||||
firefox
|
||||
vesktop
|
||||
kitty
|
||||
wofi
|
||||
thunar
|
||||
fastfetch
|
||||
waybar
|
||||
jq
|
||||
)
|
||||
|
||||
PASS=0
|
||||
FAIL=0
|
||||
MISSING=()
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
RESET='\033[0m'
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}${CYAN} Checking dependencies...${RESET}"
|
||||
echo -e " ──────────────────────────"
|
||||
|
||||
for dep in "${DEPS[@]}"; do
|
||||
if command -v "$dep" &>/dev/null; then
|
||||
echo -e " ${GREEN}✓${RESET} $dep"
|
||||
((PASS++))
|
||||
else
|
||||
echo -e " ${RED}✗${RESET} $dep ${RED}(not found)${RESET}"
|
||||
MISSING+=("$dep")
|
||||
((FAIL++))
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e " ──────────────────────────"
|
||||
echo -e " ${GREEN}${PASS} found${RESET} | ${RED}${FAIL} missing${RESET}"
|
||||
echo ""
|
||||
|
||||
if [ ${#MISSING[@]} -gt 0 ]; then
|
||||
echo -e "${BOLD} Missing:${RESET} ${MISSING[*]}"
|
||||
echo ""
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}${BOLD} All dependencies satisfied!${RESET}"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
@@ -184,7 +184,7 @@ $mainMod = SUPER # Sets "Windows" key as main modifier
|
||||
bind = $mainMod, return, exec, $terminal
|
||||
bind = $mainMod, W, killactive,
|
||||
bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit
|
||||
bind = SUPER, R, exec, sh -c '~/.config/hypr/reload.sh'
|
||||
bind = $mainMod, R, exec, sh -c '~/.config/hypr/reload.sh'
|
||||
bind = $mainMod, V, togglefloating,
|
||||
bind = $mainMod, space, exec, $menu
|
||||
bind = $mainMod, P, pseudo, # dwindle
|
||||
@@ -227,6 +227,18 @@ bind = SUPER SHIFT, left, movetoworkspacesilent, e-1
|
||||
bind = SUPER ALT, right, movefocus, r
|
||||
bind = SUPER ALT, left, movefocus, l
|
||||
|
||||
# Navigate workspaces (2D)
|
||||
#bind = SUPER, right, exec, ~/.config/hypr/2d-nav.sh right && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER, left, exec, ~/.config/hypr/2d-nav.sh left && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER, up, exec, ~/.config/hypr/2d-nav.sh up && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER, down, exec, ~/.config/hypr/2d-nav.sh down && pkill -SIGRTMIN+8 waybar
|
||||
|
||||
# Move window to workspace (2D)
|
||||
#bind = SUPER SHIFT, right, exec, ~/.config/hypr/2d-nav.sh move-right && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER SHIFT, left, exec, ~/.config/hypr/2d-nav.sh move-left && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER SHIFT, up, exec, ~/.config/hypr/2d-nav.sh move-up && pkill -SIGRTMIN+8 waybar
|
||||
#bind = SUPER SHIFT, down, exec, ~/.config/hypr/2d-nav.sh move-down && pkill -SIGRTMIN+8 waybar
|
||||
|
||||
|
||||
|
||||
# Example special workspace (scratchpad)
|
||||
@@ -300,10 +312,57 @@ windowrule {
|
||||
|
||||
move = 20 monitor_h-120
|
||||
float = yes
|
||||
|
||||
}
|
||||
|
||||
# env stuff
|
||||
exec-once = waybar
|
||||
exec-once = waybar --style ~/.config/waybar/style.css
|
||||
exec-once = hyprpaper
|
||||
exec-once = ~/.config/hypr/autostart.sh
|
||||
exec-once = ~/.config/hypr/wallpaper-cycle.sh
|
||||
exec-once = ~/.config/hypr/theme-cycle.sh
|
||||
|
||||
exec-once = [workspace 1 silent] firefox
|
||||
exec-once = [workspace 10 silent] firefox --new-instance
|
||||
|
||||
|
||||
windowrule {
|
||||
name = firefox-to-ws2
|
||||
match:class = ^(firefox)$
|
||||
workspace = 1 silent
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = code-to-ws2
|
||||
match:class = ^(code)$
|
||||
workspace = 2 silent
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = vesktop-to-ws6
|
||||
match:class = ^(vesktop)$
|
||||
workspace = 4 silent
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = vesktop-to-ws6
|
||||
match:class = ^(vesktop)$
|
||||
workspace = 4 silent
|
||||
}
|
||||
|
||||
|
||||
windowrule {
|
||||
name = steam-to-ws7
|
||||
match:class = ^(steam)$
|
||||
workspace = 6 silent
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = firefox-to-ws10
|
||||
match:class = ^(firefox)$
|
||||
workspace = 10 silent
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = eww-volume-float
|
||||
match:class = ^(eww)$
|
||||
float = yes
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
ipc = true
|
||||
splash = false
|
||||
preload = ~/.config/hypr/paper/day.jpg
|
||||
preload = ~/.config/hypr/paper/night.jpg
|
||||
preload = ~/.config/hypr/paper/night.jpg
|
||||
# check the ~/.config/hypr/theme-cycle.sh to change wallpaper
|
||||
@@ -1,11 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
killall -SIGUSR2 waybar 2>/dev/null
|
||||
# Reload Waybar if running, otherwise start it
|
||||
if pgrep -x waybar >/dev/null; then
|
||||
killall -SIGUSR2 waybar
|
||||
else
|
||||
setsid waybar &>/dev/null &
|
||||
fi
|
||||
|
||||
# Restart hyprpaper
|
||||
pkill hyprpaper 2>/dev/null
|
||||
setsid hyprpaper &>/dev/null &
|
||||
|
||||
pkill -f wallpaper-cycle.sh 2>/dev/null
|
||||
setsid ~/.config/hypr/wallpaper-cycle.sh &>/dev/null &
|
||||
# Restart wallpaper cycle script
|
||||
pkill -f theme-cycle.sh 2>/dev/null
|
||||
setsid ~/.config/hypr/theme-cycle.sh &>/dev/null &
|
||||
|
||||
# Reload Hyprland config
|
||||
hyprctl reload
|
||||
117
hypr/theme-cycle.sh
Executable file
117
hypr/theme-cycle.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DAY_HOUR=7
|
||||
NIGHT_HOUR=20
|
||||
DAY_WALL="$HOME/.config/hypr/paper/day.jpg"
|
||||
NIGHT_WALL="$HOME/.config/hypr/paper/night.jpg"
|
||||
STATE_FILE="/tmp/wallpaper-mode" # tracks: day / night / auto
|
||||
|
||||
MONITORS=( $(hyprctl monitors -j | jq -r '.[].name') )
|
||||
|
||||
apply_day() {
|
||||
for mon in "${MONITORS[@]}"; do
|
||||
hyprctl hyprpaper wallpaper "$mon,$DAY_WALL" &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
apply_night() {
|
||||
for mon in "${MONITORS[@]}"; do
|
||||
hyprctl hyprpaper wallpaper "$mon,$NIGHT_WALL" &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
wait_for_hyprpaper() {
|
||||
local retries=20
|
||||
local sock="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.hyprpaper.sock"
|
||||
[[ -S "$sock" ]] || sock="/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.hyprpaper.sock"
|
||||
while ((retries-- > 0)); do
|
||||
[[ -S "$sock" ]] && return 0
|
||||
sleep 0.3
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_state() {
|
||||
cat "$STATE_FILE" 2>/dev/null || echo "auto"
|
||||
}
|
||||
|
||||
set_state() {
|
||||
echo "$1" > "$STATE_FILE"
|
||||
}
|
||||
|
||||
# --- ARGUMENT HANDLING ---
|
||||
case "$1" in
|
||||
day)
|
||||
set_state "day"
|
||||
wait_for_hyprpaper || { echo "hyprpaper not ready"; exit 1; }
|
||||
apply_day
|
||||
exit 0
|
||||
;;
|
||||
night)
|
||||
set_state "night"
|
||||
wait_for_hyprpaper || { echo "hyprpaper not ready"; exit 1; }
|
||||
apply_night
|
||||
exit 0
|
||||
;;
|
||||
auto)
|
||||
set_state "auto"
|
||||
exit 0
|
||||
;;
|
||||
# Waybar left-click: cycle day -> night -> auto -> day
|
||||
next)
|
||||
cur=$(get_state)
|
||||
case "$cur" in
|
||||
day) "$0" night; exit 0 ;;
|
||||
night) "$0" auto; exit 0 ;;
|
||||
auto) "$0" day; exit 0 ;;
|
||||
esac
|
||||
;;
|
||||
# Waybar polls this for the button label
|
||||
status)
|
||||
cur=$(get_state)
|
||||
case "$cur" in
|
||||
day) echo '{"text":" day", "tooltip":"Wallpaper: day (click to → night)","class":"day"}' ;;
|
||||
night) echo '{"text":" night","tooltip":"Wallpaper: night (click to → auto)","class":"night"}' ;;
|
||||
auto) echo '{"text":" auto", "tooltip":"Wallpaper: auto (click to → day)","class":"auto"}' ;;
|
||||
esac
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
# No arg — fall through to cycle loop
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [day|night|auto|next|status]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- CYCLE LOOP ---
|
||||
current_mode="none"
|
||||
|
||||
while true; do
|
||||
hour=$(date +%H | sed 's/^0*//')
|
||||
state=$(get_state)
|
||||
|
||||
if [[ "$current_mode" == "none" ]]; then
|
||||
if wait_for_hyprpaper; then
|
||||
current_mode="waiting"
|
||||
fi
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
|
||||
# If pinned to day or night, just wait and recheck
|
||||
if [[ "$state" == "day" && "$current_mode" != "day" ]]; then
|
||||
apply_day; current_mode="day"
|
||||
elif [[ "$state" == "night" && "$current_mode" != "night" ]]; then
|
||||
apply_night; current_mode="night"
|
||||
elif [[ "$state" == "auto" ]]; then
|
||||
if (( hour >= DAY_HOUR && hour < NIGHT_HOUR )) && [[ "$current_mode" != "day" ]]; then
|
||||
apply_day; current_mode="day"
|
||||
elif (( hour < DAY_HOUR || hour >= NIGHT_HOUR )) && [[ "$current_mode" != "night" ]]; then
|
||||
apply_night; current_mode="night"
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep $(( 60 - $(date +%S) ))
|
||||
done
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DAY_HOUR=7
|
||||
NIGHT_HOUR=20
|
||||
|
||||
DAY_WALL="$HOME/.config/hypr/paper/day.jpg"
|
||||
NIGHT_WALL="$HOME/.config/hypr/paper/night.jpg"
|
||||
|
||||
apply_day() {
|
||||
hyprctl hyprpaper wallpaper "DP-2,$DAY_WALL" &>/dev/null
|
||||
hyprctl hyprpaper wallpaper "HDMI-A-1,$DAY_WALL" &>/dev/null
|
||||
}
|
||||
apply_night() {
|
||||
hyprctl hyprpaper wallpaper "DP-2,$NIGHT_WALL" &>/dev/null
|
||||
hyprctl hyprpaper wallpaper "HDMI-A-1,$NIGHT_WALL" &>/dev/null
|
||||
}
|
||||
|
||||
apply_now() {
|
||||
hour=$(date +%H)
|
||||
if (( hour >= DAY_HOUR && hour < NIGHT_HOUR )); then
|
||||
apply_night
|
||||
echo "night"
|
||||
else
|
||||
apply_day
|
||||
echo "day"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- FAST START ---
|
||||
current_mode=$(apply_now)
|
||||
|
||||
# If hyprpaper wasn't ready yet, retry once shortly after
|
||||
sleep 0.5
|
||||
current_mode=$(apply_now)
|
||||
|
||||
# --- MAIN LOOP ---
|
||||
while true; do
|
||||
hour=$(date +%H)
|
||||
|
||||
if (( hour >= DAY_HOUR && hour < NIGHT_HOUR )); then
|
||||
[[ "$current_mode" != "day" ]] && current_mode=$(apply_now)
|
||||
else
|
||||
[[ "$current_mode" != "night" ]] && current_mode=$(apply_now)
|
||||
fi
|
||||
|
||||
# sleep until next minute boundary (feels instant at change)
|
||||
sleep $((60 - $(date +%S)))
|
||||
done
|
||||
Reference in New Issue
Block a user