From 0d71726eca7969dd9d7782e1f9017a1de5471974 Mon Sep 17 00:00:00 2001 From: jafreli Date: Mon, 1 Jun 2026 18:59:13 +0200 Subject: [PATCH] add discord toggle --- .config/hypr/hyprland.lua | 13 +++++++++---- .config/hypr/scripts/switch_ws.sh | 18 ++++++++++++++++++ .config/hypr/scripts/toggle_discord.sh | 14 ++++++++++++++ .config/hypr/{ => scripts}/toggle_remote.sh | 0 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100755 .config/hypr/scripts/switch_ws.sh create mode 100755 .config/hypr/scripts/toggle_discord.sh rename .config/hypr/{ => scripts}/toggle_remote.sh (100%) diff --git a/.config/hypr/hyprland.lua b/.config/hypr/hyprland.lua index 8c22067..5376223 100644 --- a/.config/hypr/hyprland.lua +++ b/.config/hypr/hyprland.lua @@ -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 diff --git a/.config/hypr/scripts/switch_ws.sh b/.config/hypr/scripts/switch_ws.sh new file mode 100755 index 0000000..7d132a9 --- /dev/null +++ b/.config/hypr/scripts/switch_ws.sh @@ -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 \ No newline at end of file diff --git a/.config/hypr/scripts/toggle_discord.sh b/.config/hypr/scripts/toggle_discord.sh new file mode 100755 index 0000000..3a9dfd0 --- /dev/null +++ b/.config/hypr/scripts/toggle_discord.sh @@ -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")' \ No newline at end of file diff --git a/.config/hypr/toggle_remote.sh b/.config/hypr/scripts/toggle_remote.sh similarity index 100% rename from .config/hypr/toggle_remote.sh rename to .config/hypr/scripts/toggle_remote.sh