Reorganize repo into config/, scripts/, and docs/ directories

This commit is contained in:
duma799
2026-02-13 13:15:14 +04:00
parent 063b0b1bd0
commit c7c73546bc
33 changed files with 8 additions and 8 deletions
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
# Restarts wallpaper and caelestia shell after hyprland config reload
import os
import socket
import subprocess
import sys
import time
def get_socket_path():
xdg = os.environ.get("XDG_RUNTIME_DIR")
sig = os.environ.get("HYPRLAND_INSTANCE_SIGNATURE")
if not xdg or not sig:
return None
return f"{xdg}/hypr/{sig}/.socket2.sock"
def is_running(name):
return subprocess.run(["pgrep", "-x", name], capture_output=True).returncode == 0
def handle_reload():
time.sleep(1)
if not is_running("swaybg"):
subprocess.Popen(["waypaper", "--restore"])
if not is_running("caelestia"):
time.sleep(1)
subprocess.Popen(["caelestia", "shell", "-d"])
def listen(path):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(path)
buf = ""
while True:
data = sock.recv(4096).decode()
if not data:
break
buf += data
while "\n" in buf:
line, buf = buf.split("\n", 1)
if line.startswith("configreloaded"):
handle_reload()
sock.close()
def main():
path = get_socket_path()
if not path:
print("monitor-handler: HYPRLAND_INSTANCE_SIGNATURE not set", file=sys.stderr)
return
while True:
try:
listen(path)
except (ConnectionRefusedError, FileNotFoundError):
pass
except Exception as e:
print(f"monitor-handler: {e}", file=sys.stderr)
# Socket closed or errored — wait and retry
time.sleep(2)
# Re-check socket path in case Hyprland restarted with new signature
new_path = get_socket_path()
if new_path:
path = new_path
if __name__ == "__main__":
main()
+119
View File
@@ -0,0 +1,119 @@
#!/bin/bash
# pywal.sh - apply pywal colors
# Usage: ./pywal.sh [wallpaper_path] [light|dark]
WALLPAPER="$1"
LIGHT_MODE="$2"
echo "Applying pywal colors..."
if [ -n "$WALLPAPER" ]; then
if [ "$LIGHT_MODE" = "-l" ] || [ "$LIGHT_MODE" = "light" ]; then
wal -i "$WALLPAPER" -l
DARK_MODE=0
GTK_THEME="prefer-light"
echo "✓ Generated light theme from wallpaper"
else
wal -i "$WALLPAPER"
DARK_MODE=1
GTK_THEME="prefer-dark"
echo "✓ Generated dark theme from wallpaper"
fi
elif [ "$LIGHT_MODE" = "light" ] || [ "$LIGHT_MODE" = "-l" ]; then
wal -l
DARK_MODE=0
GTK_THEME="prefer-light"
echo "✓ Switched to light theme"
elif [ "$LIGHT_MODE" = "dark" ]; then
wal
DARK_MODE=1
GTK_THEME="prefer-dark"
echo "✓ Switched to dark theme"
else
if [ -f ~/.cache/wal/wal ]; then
wal -R
BG_COLOR=$(grep -oP 'background.*#\K[0-9A-Fa-f]{6}' ~/.cache/wal/colors.json | head -1)
if [ -n "$BG_COLOR" ]; then
R=$((16#${BG_COLOR:0:2}))
G=$((16#${BG_COLOR:2:2}))
B=$((16#${BG_COLOR:4:2}))
BRIGHTNESS=$(( (R + G + B) / 3 ))
if [ $BRIGHTNESS -gt 128 ]; then
DARK_MODE=0
GTK_THEME="prefer-light"
else
DARK_MODE=1
GTK_THEME="prefer-dark"
fi
fi
echo "✓ Refreshed existing theme"
else
echo "✗ No wallpaper specified and no existing theme found"
exit 1
fi
fi
# Caelestia wallpaper
if [ -f ~/.cache/wal/wal ]; then
WALLPAPER_PATH=$(cat ~/.cache/wal/wal)
mkdir -p ~/.local/state/caelestia/wallpaper
ln -sf "$WALLPAPER_PATH" ~/.local/state/caelestia/wallpaper/current
echo "$WALLPAPER_PATH" > ~/.local/state/caelestia/wallpaper/path.txt
echo "✓ Caelestia wallpaper reference updated"
fi
# Caelestia colors
if [ -f ~/.cache/wal/caelestia-scheme.json ]; then
mkdir -p ~/.local/state/caelestia
cp ~/.cache/wal/caelestia-scheme.json ~/.local/state/caelestia/scheme.json
echo "✓ Caelestia colors updated"
fi
# GTK themes
if command -v wal-gtk &> /dev/null; then
wal-gtk
echo "✓ GTK themes generated"
else
echo " wal-gtk not found - install 'wal-gtk-theme-git' for GTK theme support"
fi
# GTK dark/light mode
if command -v gsettings &> /dev/null; then
gsettings set org.gnome.desktop.interface color-scheme "$GTK_THEME" 2>/dev/null && \
echo "✓ System dark mode preference set to: $GTK_THEME" || \
echo " Could not set GTK color scheme preference"
fi
# Firefox
if command -v pywalfox &> /dev/null; then
pywalfox update &>/dev/null &
echo "✓ Firefox theme update triggered"
else
echo " pywalfox not found - install 'python-pywalfox' for Firefox support"
fi
# Hyprland
if command -v hyprctl &> /dev/null; then
hyprctl reload
echo "✓ Hyprland configuration reloaded"
fi
# Caelestia
if pgrep -x "caelestia" > /dev/null; then
pkill caelestia
sleep 0.5
caelestia shell -d &
echo "✓ Caelestia shell restarted"
fi
# Kitty
if command -v kitty &> /dev/null; then
if pgrep -x "kitty" > /dev/null; then
killall -SIGUSR1 kitty 2>/dev/null
echo "✓ Kitty terminal colors reloaded"
fi
fi
echo ""
echo "Done!"
echo "Current mode: $([ "$DARK_MODE" = "1" ] && echo "Dark" || echo "Light")"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Sync Caelestia wallpaper with swaybg
WALLPAPER_PATH=$(pgrep -a swaybg | grep -oP '(?<=-i )[^ ]+' | head -1)
if [ -n "$WALLPAPER_PATH" ] && [ -f "$WALLPAPER_PATH" ]; then
mkdir -p ~/.local/state/caelestia/wallpaper
ln -sf "$WALLPAPER_PATH" ~/.local/state/caelestia/wallpaper/current
echo "$WALLPAPER_PATH" > ~/.local/state/caelestia/wallpaper/path.txt
echo "✓ Caelestia wallpaper synced to: $WALLPAPER_PATH"
else
echo "⚠ Could not detect swaybg wallpaper"
fi
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
# Waypaper hook - applies pywal colors on wallpaper change
LOCK_FILE="/tmp/waypaper-hook.lock"
LOG_FILE="/tmp/waypaper-hook.log"
if [ -f "$LOCK_FILE" ]; then
LOCK_PID=$(cat "$LOCK_FILE" 2>/dev/null)
if [ -n "$LOCK_PID" ] && kill -0 "$LOCK_PID" 2>/dev/null; then
echo "Hook already running (PID: $LOCK_PID), skipping..." >> "$LOG_FILE"
exit 0
fi
fi
echo $$ > "$LOCK_FILE"
trap "rm -f $LOCK_FILE" EXIT
echo "=== Waypaper hook triggered at $(date) ===" >> "$LOG_FILE"
sleep 0.5
# Get wallpaper from waypaper config
WALLPAPER=$(grep "^wallpaper = " ~/.config/waypaper/config.ini | cut -d' ' -f3-)
WALLPAPER="${WALLPAPER/#\~/$HOME}"
# Fallback: swaybg process
if [ ! -f "$WALLPAPER" ]; then
WALLPAPER=$(pgrep -a swaybg | grep -oP '(?<=-i )[^ ]+' | head -1)
fi
if [ -f "$WALLPAPER" ]; then
echo "Applying pywal for wallpaper: $WALLPAPER" >> "$LOG_FILE"
# Resolve pywal.sh location (same directory as this hook, or ~/pywal.sh)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PYWAL_SCRIPT="$SCRIPT_DIR/pywal.sh"
if [ ! -f "$PYWAL_SCRIPT" ]; then
PYWAL_SCRIPT="$HOME/pywal.sh"
fi
if [ -f "$PYWAL_SCRIPT" ]; then
bash "$PYWAL_SCRIPT" "$WALLPAPER" >> "$LOG_FILE" 2>&1
else
echo "✗ pywal.sh not found" >> "$LOG_FILE"
exit 1
fi
echo "✓ Waypaper hook completed at $(date)" >> "$LOG_FILE"
else
echo "✗ Wallpaper file not found: $WALLPAPER" >> "$LOG_FILE"
exit 1
fi