Table of Contents
- Hypridle zu swayidle Port - README
- Erfolgreich portierte Features
- Architektur-Unterschiede
- 1. Konfigurationsformat
- 2. General Block
- 3. Listener vs. Timeout
- 4. DPMS Befehle
- 5. Pidof-Check für Lock Command
- 6. Conditional Execution
- 7. DBus Inhibit
- 8. Multiple Resume Commands
- 9. Screen Dimming
- 10. Config File Support
- Portierte Konfiguration
- Deine Original Hypridle Config:
- Portiert zu swayidle (Kommandozeile):
- Portiert zu swayidle (Config-Datei):
- Verwendung
- Compositor-spezifische DPMS-Befehle
- Zusätzliche swayidle Features
- Unterschiede zu Hypridle
- Troubleshooting
- swayidle startet nicht
- Lock funktioniert nicht
- DPMS funktioniert nicht
- Mehrere swayidle-Instanzen
- Conditional Lock funktioniert nicht
- Config-Datei wird nicht gelesen
- Nützliche Kommandos
- Systemd Service (Optional)
- Erweiterte Konfiguration
- Weitere Ressourcen
Hypridle zu swayidle Port - README
Diese Datei dokumentiert alle Unterschiede, Einschränkungen und Features beim Portieren von hypridle zu swayidle.
Erfolgreich portierte Features
- ✅ Timeout-basiertes Locking (30 Minuten)
- ✅ DPMS (Monitor ausschalten nach 60 Minuten)
- ✅ before-sleep Hook (Lock vor Suspend/Hibernate)
- ✅ Resume-Funktion (Monitor wieder einschalten)
- ✅ Conditional Lock (nur locken wenn kein Audio läuft)
- ✅ Brightness dimming (optional)
- ✅ Systemd integration
- ✅ DBus inhibit support
Architektur-Unterschiede
1. Konfigurationsformat
Hypridle: Eigenes Config-Format mit general {} und listener {} Blöcken
general {
lock_cmd = pidof hyprlock || hyprlock
before_sleep_cmd = loginctl lock-session
}
listener {
timeout = 1800
on-timeout = loginctl lock-session
}
swayidle: Kommandozeilen-Argumente oder einfache Config-Datei
# Als Kommando:
swayidle -w timeout 1800 'loginctl lock-session' before-sleep 'loginctl lock-session'
# Oder in config file:
timeout 1800 loginctl lock-session
before-sleep loginctl lock-session
Status: Portiert - beide Varianten (Skript und Config-Datei) erstellt
2. General Block
Hypridle:
general {
lock_cmd = pidof hyprlock || hyprlock
before_sleep_cmd = loginctl lock-session
after_sleep_cmd = hyprctl dispatch dpms on
ignore_dbus_inhibit = false
}
swayidle: Kein general Block
lock_cmd→lock 'command'Eventbefore_sleep_cmd→before-sleep 'command'after_sleep_cmd→after-resume 'command'ignore_dbus_inhibit→ Keine direkte Option (respektiert immer DBus inhibits)
Portierung:
# hypridle: lock_cmd
swayidle lock 'pidof swaylock || swaylock'
# hypridle: before_sleep_cmd
swayidle before-sleep 'loginctl lock-session'
# hypridle: after_sleep_cmd
swayidle after-resume 'niri msg action power-on-monitors'
Status: Vollständig portiert mit anderen Keywords
3. Listener vs. Timeout
Hypridle: listener {} Blöcke
listener {
timeout = 1800
on-timeout = loginctl lock-session
on-resume = # optional
}
swayidle: timeout Keyword
timeout 1800 'loginctl lock-session' resume 'command'
Unterschiede:
- Hypridle: Separate listener-Blöcke für jeden Timeout
- swayidle: Inline timeout-Definitionen
Status: Identische Funktionalität, nur andere Syntax
4. DPMS Befehle
Hypridle (Hyprland-spezifisch):
on-timeout = hyprctl dispatch dpms off
on-resume = hyprctl dispatch dpms on
swayidle (Niri-angepasst):
timeout 3600 'niri msg action power-off-monitors'
resume 'niri msg action power-on-monitors'
Für Sway:
timeout 3600 'swaymsg "output * dpms off"'
resume 'swaymsg "output * dpms on"'
Status: Portiert mit Niri-Befehlen (compositor-spezifisch)
5. Pidof-Check für Lock Command
Hypridle:
lock_cmd = pidof hyprlock || hyprlock
Hypridle führt lock_cmd automatisch aus und verhindert mehrere Instanzen.
swayidle:
lock 'pidof swaylock || swaylock'
swayidle führt den Lock-Befehl aus, aber der pidof-Check muss im Befehl selbst sein.
Alternative: swaylock's -f (fork) Flag verhindert mehrfache Instanzen:
lock 'swaylock -f'
Status: Funktioniert identisch
6. Conditional Execution
Hypridle:
on-timeout = pactl list sinks | grep -q "State: RUNNING" || loginctl lock-session
swayidle:
timeout 1800 'sh -c "pactl list sinks | grep -q \"State: RUNNING\" || loginctl lock-session"'
Wichtig: Bei swayidle muss komplexe Shell-Logik in sh -c "..." gewrappt werden!
Status: Portiert mit sh -c wrapper
7. DBus Inhibit
Hypridle:
general {
ignore_dbus_inhibit = false # Respektiert DBus inhibits
}
swayidle: Kein explizites Flag
- swayidle respektiert standardmäßig systemd inhibitor locks
- Keine Option zum Ignorieren von DBus inhibits
- Verhält sich wie
ignore_dbus_inhibit = false
Status: Standardverhalten ist identisch zu Hypridle's false Setting
8. Multiple Resume Commands
Hypridle:
listener {
timeout = 1800
on-timeout = command1
}
listener {
timeout = 3600
on-timeout = command2
on-resume = command3
}
Jeder listener kann eigene on-resume Commands haben.
swayidle:
timeout 1800 'command1'
timeout 3600 'command2' resume 'command3'
Wichtig: In swayidle gilt resume für alle Timeouts, nicht nur für den letzten!
Workaround: Wenn du unterschiedliche resume-Befehle brauchst, musst du prüfen, welcher Timeout ausgelöst wurde:
timeout 1800 'command1'
timeout 3600 'command2; touch /tmp/long-idle'
resume 'if [ -f /tmp/long-idle ]; then rm /tmp/long-idle; command3; fi'
Status: Limitierung - nur ein globales resume
9. Screen Dimming
Hypridle:
listener {
timeout = 300
on-timeout = brightnessctl -s set 10%
on-resume = brightnessctl -r
}
swayidle:
timeout 300 'brightnessctl -s set 10%' resume 'brightnessctl -r'
Status: Identisch portierbar
10. Config File Support
Hypridle: Benötigt immer eine Config-Datei
hypridle # Liest ~/.config/hypr/hypridle.conf
swayidle: Optional - Kommandozeile oder Config-Datei
# Ohne Config:
swayidle -w timeout 300 'command'
# Mit Config:
swayidle -w -C ~/.config/swayidle/config
Status: Flexibler als Hypridle
Portierte Konfiguration
Deine Original Hypridle Config:
general {
lock_cmd = pidof hyprlock || hyprlock
before_sleep_cmd = loginctl lock-session
after_sleep_cmd = hyprctl dispatch dpms on
ignore_dbus_inhibit = false
}
listener {
timeout = 1800
on-timeout = pactl list sinks | grep -q "State: RUNNING" || loginctl lock-session
}
listener {
timeout = 3600
on-timeout = pactl list sinks | grep -q "State: RUNNING" || hyprctl dispatch dpms off
on-resume = hyprctl dispatch dpms on
}
Portiert zu swayidle (Kommandozeile):
swayidle -w \
timeout 1800 'sh -c "pactl list sinks | grep -q \"State: RUNNING\" || loginctl lock-session"' \
timeout 3600 'sh -c "pactl list sinks | grep -q \"State: RUNNING\" || niri msg action power-off-monitors"' \
resume 'niri msg action power-on-monitors' \
before-sleep 'loginctl lock-session' \
lock 'pidof swaylock || swaylock' \
&
Portiert zu swayidle (Config-Datei):
# ~/.config/swayidle/config
timeout 1800 sh -c "pactl list sinks | grep -q \"State: RUNNING\" || loginctl lock-session"
timeout 3600 sh -c "pactl list sinks | grep -q \"State: RUNNING\" || niri msg action power-off-monitors"
resume niri msg action power-on-monitors
before-sleep loginctl lock-session
lock pidof swaylock || swaylock
Verwendung
Option 1: Startup-Skript (empfohlen)
# Skript ist bereits ausführbar
./swayidle/start-swayidle.sh
# In niri config.kdl einbinden:
spawn-at-startup "/home/zenn/opt/projects/niri/swayidle/start-swayidle.sh"
Option 2: Mit Config-Datei
# Config installieren
mkdir -p ~/.config/swayidle
cp swayidle/config ~/.config/swayidle/config
# Starten
swayidle -w -C ~/.config/swayidle/config &
# In niri config.kdl:
spawn-sh-at-startup "swayidle -w -C ~/.config/swayidle/config &"
Option 3: Direkt in niri config.kdl
spawn-sh-at-startup "swayidle -w timeout 1800 'sh -c \"pactl list sinks | grep -q \\\"State: RUNNING\\\" || loginctl lock-session\"' timeout 3600 'sh -c \"pactl list sinks | grep -q \\\"State: RUNNING\\\" || niri msg action power-off-monitors\"' resume 'niri msg action power-on-monitors' before-sleep 'loginctl lock-session' lock 'swaylock' &"
(Achtung: Escaping wird komplex!)
Compositor-spezifische DPMS-Befehle
Niri (aktuell):
# Monitor aus
niri msg action power-off-monitors
# Monitor an
niri msg action power-on-monitors
Sway:
# Monitor aus
swaymsg "output * dpms off"
# Monitor an
swaymsg "output * dpms on"
Hyprland (original):
# Monitor aus
hyprctl dispatch dpms off
# Monitor an
hyprctl dispatch dpms on
Zusätzliche swayidle Features
swayidle hat einige Features, die Hypridle nicht hat:
1. idlehint
swayidle idlehint 300
Setzt systemd's IdleHint nach 300 Sekunden. Nützlich für systemd-integration.
2. unlock Event
swayidle unlock 'notify-send "Session unlocked"'
Wird ausgeführt, wenn die Session entsperrt wird.
3. -S (Seat Selection)
swayidle -S seat0 timeout 300 'swaylock'
Überwacht nur einen bestimmten Seat (für Multi-User-Setups).
4. -d (Debug Mode)
swayidle -d -w timeout 300 'swaylock'
Zeigt Debug-Informationen an.
Unterschiede zu Hypridle
| Feature | Hypridle | swayidle |
|---|---|---|
| Config-Format | Eigenes Format | Kommandozeile oder simple config |
| General Block | ✅ | ❌ (keywords stattdessen) |
| Listener Blocks | ✅ | ❌ (inline timeouts) |
| Multiple Resume | ✅ (per listener) | ⚠️ (global) |
| DBus Inhibit Control | ✅ | ❌ (immer aktiv) |
| Lock Command | lock_cmd |
lock event |
| Before Sleep | before_sleep_cmd |
before-sleep |
| After Sleep | after_sleep_cmd |
after-resume |
| Pidof Check | Automatisch | Manuell im Befehl |
| Config-Datei Pflicht | ✅ | ❌ (optional) |
| Debug Mode | ❓ | ✅ (-d flag) |
| Seat Selection | ❌ | ✅ (-S flag) |
| idlehint | ❌ | ✅ |
| unlock Event | ❌ | ✅ |
Legende:
- ✅ Unterstützt
- ⚠️ Eingeschränkt unterstützt
- ❌ Nicht unterstützt
- ❓ Unklar
Troubleshooting
swayidle startet nicht
# Check installation
which swayidle
# Debug mode
swayidle -d -w timeout 300 'echo "test"'
# Check logs
journalctl --user -u niri -f
Lock funktioniert nicht
# Test swaylock manuell
swaylock
# Check ob swaylock installiert ist
which swaylock
# Test mit loginctl
loginctl lock-session
DPMS funktioniert nicht
# Test Niri DPMS
niri msg action power-off-monitors
sleep 2
niri msg action power-on-monitors
# Check verfügbare outputs
niri msg outputs
Mehrere swayidle-Instanzen
# Alle beenden
killall swayidle
# Laufende Instanzen prüfen
ps aux | grep swayidle
# Neu starten
./swayidle/start-swayidle.sh
Conditional Lock funktioniert nicht
# Test audio detection
pactl list sinks | grep "State: RUNNING"
echo $? # sollte 0 sein wenn Audio läuft
# Test mit sh -c wrapper
sh -c "pactl list sinks | grep -q \"State: RUNNING\" || echo 'no audio'"
Config-Datei wird nicht gelesen
# Config-Pfad prüfen
ls -lh ~/.config/swayidle/config
# Mit explizitem Pfad starten
swayidle -w -C ~/.config/swayidle/config
# Syntax prüfen
cat ~/.config/swayidle/config
Nützliche Kommandos
# swayidle mit Debug-Output starten
swayidle -d -w timeout 300 'swaylock'
# Sofort locken (ohne timeout)
loginctl lock-session
# swayidle neu starten
killall swayidle && swayidle -w -C ~/.config/swayidle/config &
# Check ob swayidle läuft
pgrep -a swayidle
# Systemd-Integration
systemctl --user status swayidle.service # falls service existiert
# Manual DPMS test
niri msg action power-off-monitors
sleep 5
niri msg action power-on-monitors
Systemd Service (Optional)
Für automatisches Starten via systemd:
# ~/.config/systemd/user/swayidle.service
[Unit]
Description=Idle manager for Wayland
Documentation=man:swayidle(1)
PartOf=graphical-session.target
[Service]
Type=simple
ExecStart=%h/opt/projects/niri/swayidle/start-swayidle.sh
Restart=on-failure
[Install]
WantedBy=niri.service
# Service aktivieren
systemctl --user enable swayidle.service
systemctl --user start swayidle.service
# Status checken
systemctl --user status swayidle.service
Erweiterte Konfiguration
Mit Screen Dimming
swayidle -w \
timeout 300 'brightnessctl -s set 10%' \
resume 'brightnessctl -r' \
timeout 1800 'sh -c "pactl list sinks | grep -q \"State: RUNNING\" || loginctl lock-session"' \
timeout 3600 'sh -c "pactl list sinks | grep -q \"State: RUNNING\" || niri msg action power-off-monitors"' \
resume 'niri msg action power-on-monitors' \
before-sleep 'loginctl lock-session' \
lock 'swaylock' \
&
Mit Suspend
swayidle -w \
timeout 1800 'loginctl lock-session' \
timeout 3600 'niri msg action power-off-monitors' \
resume 'niri msg action power-on-monitors' \
timeout 7200 'systemctl suspend' \
before-sleep 'loginctl lock-session' \
lock 'swaylock' \
&
Mit Benachrichtigungen
swayidle -w \
timeout 1800 'notify-send "Locking in 10 seconds..." && sleep 10 && loginctl lock-session' \
timeout 3600 'niri msg action power-off-monitors' \
resume 'niri msg action power-on-monitors' \
before-sleep 'loginctl lock-session' \
lock 'swaylock' \
unlock 'notify-send "Session unlocked"' \
&
Weitere Ressourcen
Generiert am: 2025-10-27 Von: Hypridle → swayidle Config Converter Empfehlung: Verwende das start-swayidle.sh Skript für einfache Verwaltung