add discord toggle

This commit is contained in:
2026-06-01 18:59:13 +02:00
parent 1bb979d7d3
commit 0d71726eca
4 changed files with 41 additions and 4 deletions

View File

@@ -12,6 +12,8 @@ local menu = "wofi"
local webBrowser = "firefox"
local codeEditor = "code-insiders"
local discordSpecial = "discord"
local discordWorkspace = "special:" .. discordSpecial
------------------------------------------
local mainMod = "SUPER"
@@ -180,12 +182,14 @@ for _, ws in ipairs({2, 4, 6, 8, 10}) do
hl.workspace_rule({ workspace = tostring(ws), monitor = "DP-2" })
end
hl.workspace_rule({ workspace = discordWorkspace, monitor = "DP-2" })
-- ==========================================
-- KEYBINDS
-- ==========================================
-- Die neue hl.bind()-Funktion kombiniert Modifier und Taste per String
hl.bind(mainMod .. " + D", hl.dsp.exec_cmd("discord"))
hl.bind(mainMod .. " + D", hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle_discord.sh"))
hl.bind(mainMod .. " + Q", hl.dsp.exec_cmd(terminal))
hl.bind(mainMod .. " + C", hl.dsp.window.close())
hl.bind(mainMod .. " + M", hl.dsp.exec_cmd("command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch 'hl.dsp.exit()'"))
@@ -198,7 +202,7 @@ hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit"))
hl.bind(mainMod .. " + SHIFT + B", hl.dsp.exec_cmd("~/.config/waybar/refrech.sh"))
hl.bind(mainMod .. " + L", hl.dsp.exec_cmd("hyprlock"))
hl.bind(mainMod .. " + SHIFT + L", hl.dsp.exec_cmd("systemctl suspend"))
hl.bind(mainMod .. " + SHIFT + R", hl.dsp.exec_cmd("~/.config/hypr/toggle_remote.sh"))
hl.bind(mainMod .. " + SHIFT + R", hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle_remote.sh"))
-- Move focus with mainMod + arrow keys
hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" }))
@@ -210,7 +214,8 @@ hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" }))
-- Move active window to a workspace with mainMod + SHIFT + [0-9]
for i = 1, 10 do
local key = i % 10 -- 10 maps to key 0
hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i}))
-- Führt ab sofort unser cleveres Switch-Skript aus!
hl.bind(mainMod .. " + " .. key, hl.dsp.exec_cmd("~/.config/hypr/scripts/switch_ws.sh " .. i))
hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i }))
end
@@ -250,7 +255,7 @@ hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = tr
-- FENSTERREGELN (hl.window_rule)
-- ==========================================
-- In v0.55 nutzt du für Fensterregeln eine saubere Table-Struktur für Matches
hl.window_rule({ match = { class = "^(discord)$" }, workspace = "2" })
hl.window_rule({ match = { class = "^(discord)$" }, workspace = discordWorkspace })
hl.window_rule({ match = { class = "^(steam)$", title = "^(Steam)$" }, workspace = "5" })
-- Maximize-Events von allen Apps unterdrücken

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
TARGET_WS=$1
# 1. WICHTIG: Zuerst zum gewählten Workspace wechseln!
# Dadurch springt unser Fokus sicher auf den richtigen Monitor (z.B. DP-2).
hyprctl dispatch 'hl.dsp.focus({ workspace = '"$TARGET_WS"' })'
# 2. Ist der Ziel-Workspace eine gerade Zahl (2, 4, 6, 8, 10)?
if [[ "$TARGET_WS" =~ ^(2|4|6|8|10)$ ]]; then
# 3. Prüfen: Ist das Discord-Overlay offen?
if hyprctl monitors | grep -iq "special.*workspace.*discord"; then
# 4. Zuklappen! (Da wir jetzt sicher auf DP-2 fokussiert sind, bleibt es auch dort)
hyprctl dispatch 'hl.dsp.workspace.toggle_special("discord")'
fi
fi

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# 1. Prüfen, ob der Discord-Prozess (egal ob groß/klein geschrieben) läuft
if ! pgrep -i "discord" > /dev/null; then
# Starten, falls nicht
discord > /dev/null 2>&1 &
exit 0
fi
# 2. Zuerst zwingend DP-2 fokussieren (angepasst an deine Lua-Syntax)
hyprctl dispatch 'hl.dsp.focus({ monitor = "DP-2" })'
# 3. Dein funktionierender Befehl zum Ein-/Ausklappen!
hyprctl dispatch 'hl.dsp.workspace.toggle_special("discord")'