From c0706258b1ff22c70f6c0e51c4b812e63703f620 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 16 May 2026 23:27:26 +0200 Subject: [PATCH] add back some repetitive keybinds to cheatsheet --- dots/.config/hypr/hyprland/keybinds.lua | 182 +++++++++++------- .../ii/cheatsheet/CheatsheetKeybinds.qml | 7 + .../cheatsheet/CheatsheetKeybindsCategory.qml | 74 +++++-- 3 files changed, 173 insertions(+), 90 deletions(-) diff --git a/dots/.config/hypr/hyprland/keybinds.lua b/dots/.config/hypr/hyprland/keybinds.lua index 28435e68a..174127019 100644 --- a/dots/.config/hypr/hyprland/keybinds.lua +++ b/dots/.config/hypr/hyprland/keybinds.lua @@ -16,8 +16,10 @@ hl.bind("SUPER + SUPER_R", hl.dsp.exec_cmd(qsIsAlive .. " || pkill fuzzel || fuz hl.bind("SUPER_L", hl.dsp.global("quickshell:workspaceNumber"), { ignore_mods = true, transparent = true }) hl.bind("SUPER_R", hl.dsp.global("quickshell:workspaceNumber"), { ignore_mods = true, transparent = true }) -hl.bind("SUPER_L", hl.dsp.global("quickshell:workspaceNumber"), { ignore_mods = true, transparent = true, release = true }) -hl.bind("SUPER_R", hl.dsp.global("quickshell:workspaceNumber"), { ignore_mods = true, transparent = true, release = true }) +hl.bind("SUPER_L", hl.dsp.global("quickshell:workspaceNumber"), + { ignore_mods = true, transparent = true, release = true }) +hl.bind("SUPER_R", hl.dsp.global("quickshell:workspaceNumber"), + { ignore_mods = true, transparent = true, release = true }) hl.bind("SUPER + Tab", hl.dsp.global("quickshell:overviewWorkspacesToggle"), { description = "Shell: Toggle overview" }) hl.bind("SUPER + V", hl.dsp.global("quickshell:overviewClipboardToggle")) hl.bind("SUPER + Period", hl.dsp.global("quickshell:overviewEmojiToggle")) @@ -45,9 +47,9 @@ hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO { locked = true, repeating = true }) hl.bind("CTRL + SUPER + T", hl.dsp.global("quickshell:wallpaperSelectorToggle"), - { description = "Shell: Toggle wallpaper selector" }) + { description = "Shell: Change wallpaper" }) hl.bind("CTRL + SUPER + ALT + T", hl.dsp.global("quickshell:wallpaperSelectorRandom"), - { description = "Shell: Select random wallpaper" }) + { description = "Shell: Random wallpaper" }) hl.bind("CTRL + SUPER + SHIFT + D", hl.dsp.global("quickshell:toggleLightDark"), { description = "Shell: Toggle light/dark mode" }) hl.bind("CTRL + SUPER + T", hl.dsp.exec_cmd(qsIsAlive .. " || " .. qsScripts .. "/colors/switchwall.sh")) @@ -58,10 +60,10 @@ hl.bind("CTRL + SUPER + P", hl.dsp.global("quickshell:panelFamilyCycle"), { desc --##! Utilities --# Screenshot, Record, OCR, Color picker, Clipboard history hl.bind("SUPER + V", hl.dsp.exec_cmd( - qsIsAlive .. " || pkill fuzzel || cliphist list | fuzzel --match-mode fzf --dmenu | cliphist decode | wl-copy"), + qsIsAlive .. " || pkill fuzzel || cliphist list | fuzzel --match-mode fzf --dmenu | cliphist decode | wl-copy"), { description = "Utilities: Clipboard history >> clipboard" }) hl.bind("SUPER + Period", hl.dsp.exec_cmd( - qsIsAlive .. " || pkill fuzzel || " .. hyprScripts .. "/fuzzel-emoji.sh copy"), + qsIsAlive .. " || pkill fuzzel || " .. hyprScripts .. "/fuzzel-emoji.sh copy"), { description = "Utilities: Emoji >> clipboard" }) hl.bind("SUPER + SHIFT + S", hl.dsp.global("quickshell:regionScreenshot"), { description = "Utilities: Screen snip" }) hl.bind("SUPER + SHIFT + S", @@ -103,6 +105,47 @@ hl.bind("SUPER + SHIFT + ALT + mouse:273", hl.dsp.exec_cmd(hyprScripts .. "/ai/p { description = "Utilities: Generate AI summary for selected text" }) -- (requires a running ollama model) +--##! Screen +--# Zoom +local function zoomfunction(value) + local zoomvalue = hl.get_config("cursor:zoom_factor") + if (zoomvalue + value) > 3.0 then + hl.config({ cursor = { zoom_factor = 3.0 } }) + elseif (zoomvalue + value) < 1.0 then + hl.config({ cursor = { zoom_factor = 1.0 } }) + else + hl.config({ cursor = { zoom_factor = zoomvalue + value } }) + end +end +hl.bind("SUPER + Minus", function() zoomfunction(-0.3) end, { repeating = true, description = "Screen: Zoom out" }) +hl.bind("SUPER + Equal", function() zoomfunction(0.3) end, { repeating = true, description = "Screen: Zoom in" }) + +--# Zoom with keypad +hl.bind("SUPER + code:82", function() zoomfunction(-0.3) end, { repeating = true }) +hl.bind("SUPER + code:86", function() zoomfunction(0.3) end, { repeating = true }) + +--##! Media +local mediaNextCommand = +"playerctl next || playerctl position `bc <<< \"100 * $(playerctl metadata mpris:length) / 1000000 / 100\"`" +hl.bind("SUPER + SHIFT + N", hl.dsp.exec_cmd(mediaNextCommand), { locked = true, description = "Media: Next track" }) +hl.bind("XF86AudioNext", hl.dsp.exec_cmd(mediaNextCommand), { locked = true }) +hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) +hl.bind("SUPER + SHIFT + ALT + mouse:275", hl.dsp.exec_cmd("playerctl previous")) +hl.bind("SUPER + SHIFT + ALT + mouse:276", hl.dsp.exec_cmd(mediaNextCommand)) +hl.bind("SUPER + SHIFT + B", hl.dsp.exec_cmd("playerctl previous"), + { locked = true, description = "Media: Previous track" }) +hl.bind("SUPER + SHIFT + P", hl.dsp.exec_cmd("playerctl play-pause"), + { locked = true, description = "Media: Play/pause media" }) +hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) +hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) +hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SINK@ toggle"), { locked = true }) +hl.bind("SUPER + SHIFT + M", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SINK@ toggle"), + { locked = true, description = "Media: Toggle mute" }) +hl.bind("ALT + XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), { locked = true }) +hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), { locked = true }) +hl.bind("SUPER + ALT + M", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), + { locked = true, description = "Media: Toggle mic" }) + --#! --##! Window --# Focusing @@ -110,21 +153,30 @@ hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), { mouse = true, description = hl.bind("SUPER + mouse:274", hl.dsp.window.drag(), { mouse = true }) hl.bind("SUPER + mouse:273", hl.dsp.window.resize(), { mouse = true, description = "Window: Resize" }) --#/# bind = SUPER + ←/↑/→/↓,, -- Focus in direction -for i = 1, 6 do - local arrowkey = { "Left", "Right", "Up", "Down", "BracketLeft", "BracketRight" } - local focusdir = { "l", "r", "u", "d", "l", "r" } +for i = 1, 4 do + local arrowkey = { "Left", "Right", "Up", "Down" } + local focusdir = { "l", "r", "u", "d" } + hl.bind("SUPER + " .. arrowkey[i], hl.dsp.focus({ direction = focusdir[i] }), + { description = "Window: Focus " .. arrowkey[i] }) +end +for i = 1, 2 do + local arrowkey = { "BracketLeft", "BracketRight" } + local focusdir = { "l", "r" } hl.bind("SUPER + " .. arrowkey[i], hl.dsp.focus({ direction = focusdir[i] })) end --#/# bind = SUPER + SHIFT, ←/↑/→/↓,, -- Move in direction for i = 1, 4 do local arrowkey = { "Left", "Right", "Up", "Down" } local focusdir = { "l", "r", "u", "d" } - hl.bind("SUPER + SHIFT + " .. arrowkey[i], hl.dsp.window.move({ direction = focusdir[i] })) + hl.bind("SUPER + SHIFT + " .. arrowkey[i], hl.dsp.window.move({ direction = focusdir[i] }), + { description = "Window: Move " .. arrowkey[i] }) end hl.bind("ALT + F4", - function() hl.exec_cmd( - "notify-send \"Wrong close keybind\" \"Super+Q to close. Use Alt+F4 for Windows VMs\" -a Hyprland") end, + function() + hl.exec_cmd( + "notify-send \"Wrong close keybind\" \"Super+Q to close. Use Alt+F4 for Windows VMs\" -a Hyprland") + end, { non_consuming = true }) hl.bind("SUPER + Q", hl.dsp.window.close(), { description = "Window: Close" }) hl.bind("SUPER + SHIFT + ALT + Q", hl.dsp.exec_cmd("hyprctl kill"), { description = "Window: Forcefully zap a window" }) @@ -144,7 +196,12 @@ hl.bind("SUPER + ALT + F", hl.dsp.window.fullscreen_state({ internal = 0, client hl.bind("SUPER + P", hl.dsp.window.pin(), { description = "Window: Pin" }) --#/# bind = SUPER+ALT, Hash,, -- Send to workspace -- (1, 2, 3,...) ---# We use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev` +for i = 1, 10 do + hl.bind("SUPER + ALT + " .. (i % 10), function() + hl.dispatch(hl.dsp.window.move({ workspace = workspace_in_group(i), follow = false })) + end, { description = "Window: Send to workspace " .. i }) +end +--# We also use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev` for i = 1, 10 do local numberkey = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 } hl.bind("SUPER + ALT + code:" .. numberkey[i], function() @@ -163,27 +220,37 @@ end for i = 1, 4 do local key = { "SUPER + SHIFT + mouse_", "SUPER + ALT + mouse_" } local keycombos = { key[1] .. "down", key[1] .. "up", key[2] .. "down", key[2] .. "up" } - local prefix = { "r-", "r+", "-", "+" } + local prefix = { "r-", "r+", "r-", "r+" } hl.bind(keycombos[i], hl.dsp.window.move({ workspace = prefix[i] .. "1" })) end --#/# bind = SUPER+SHIFT, Page_↑/↓,, -- Send to workspace left/right -for i = 1, 6 do - local key = { "SUPER + ALT + Page_", "SUPER + SHIFT + Page_", "CTRL + SUPER + SHIFT + " } - local keycombos = { key[1] .. "down", key[1] .. "up", key[2] .. "down", key[2] .. "up", key[3] .. "Right", key[3] .. - "Left" } - local prefix = { "+", "-", "r+", "r-", "r+", "r-" } +for i = 1, 2 do + local keydirs = { "Up", "Down" } + local prefix = { "r-", "r+" } + local descdir = { "left", "right" } + hl.bind("SUPER + SHIFT + Page_" .. keydirs[i], hl.dsp.window.move({ workspace = prefix[i] .. "1" }), {description = "Window: Send to workspace " .. descdir[i]}) +end +for i = 1, 4 do + local key = { "SUPER + ALT + Page_", "CTRL + SUPER + SHIFT + " } + local keycombos = { key[1] .. "down", key[1] .. "up", key[2] .. "Right", key[2] .. "Left" } + local prefix = { "r+", "r-", "r+", "r-" } hl.bind(keycombos[i], hl.dsp.window.move({ workspace = prefix[i] .. "1" })) -- # [hidden] end hl.bind("SUPER + ALT + S", - hl.dsp.window.move({ workspace = "special:special", follow = false }), {description = "Window: Send to scratchpad"}) + hl.dsp.window.move({ workspace = "special:special", follow = false }), { description = "Window: Send to scratchpad" }) hl.bind("CTRL + SUPER + S", hl.dsp.workspace.toggle_special("special")) --##! Workspace --# Switching --#/# bind = SUPER, Hash,, -- Focus workspace -- (1, 2, 3,...) ---# We use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev` +for i = 1, 10 do + hl.bind("SUPER + " .. (i % 10), function() + hl.dispatch(hl.dsp.focus({ workspace = workspace_in_group(i) })) + end, { description = "Workspace: Focus " .. i }) +end +--# We also use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev` for i = 1, 10 do local numberkey = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 } hl.bind("SUPER + code:" .. numberkey[i], function() @@ -200,11 +267,16 @@ end --#/# bind = CTRL+SUPER, ←/→,, -- Focus left/right --#/# bind = CTRL+SUPER+ALT, ←/→,, -- # [hidden] Focus busy left/right -for i = 1, 4 do - local key = { "CTRL + SUPER + ", "CTRL + SUPER + ALT + " } - local keycombos = { key[1] .. "Right", key[1] .. "Left", key[2] .. "Right", key[2] .. "Left" } - local prefix = { "r+", "r-", "m+", "m-" } - hl.bind(keycombos[i], hl.dsp.focus({ workspace = prefix[i] .. "1" })) +for i = 1, 2 do + local keys = { "Left", "Right" } + local prefix = { "r-", "r+" } + local descdir = { "left", "right" } + hl.bind("CTRL + SUPER + " .. keys[i], hl.dsp.focus({ workspace = prefix[i] .. "1" }), {description = "Workspace: Focus " .. descdir[i]}) +end +for i = 1, 2 do + local keys = { "Left", "Right" } + local prefix = { "m-", "m+" } + hl.bind("CTRL + SUPER + ALT + " .. keys[i], hl.dsp.focus({ workspace = prefix[i] .. "1" })) end --#/# bind = SUPER, Page_↑/↓,, -- Focus left/right for i = 1, 4 do @@ -235,11 +307,11 @@ hl.define_submap("virtual-machine", function() local currentsubmap = hl.get_current_submap() if currentsubmap == "virtual-machine" then hl.dispatch(hl.dsp.exec_cmd( - "notify-send 'Exited Virtual Machine submap' 'Keybinds re-enabled' -a 'Hyprland'")) + "notify-send 'Exited Virtual Machine submap' 'Keybinds re-enabled' -a 'Hyprland'")) hl.dispatch(hl.dsp.submap("reset")) elseif currentsubmap == "" then hl.dispatch(hl.dsp.exec_cmd( - "notify-send 'Entered Virtual Machine submap' 'Keybinds disabled. hit SUPER+ALT+F1 to escape' -a 'Hyprland'")) + "notify-send 'Entered Virtual Machine submap' 'Keybinds disabled. hit SUPER+ALT+F1 to escape' -a 'Hyprland'")) hl.dispatch(hl.dsp.submap("virtual-machine")) end end, { submap_universal = true }) @@ -250,63 +322,25 @@ end) --# Testing hl.bind("SUPER + ALT + F11", hl.dsp.exec_cmd( - "bash -c 'RANDOM_IMAGE=$(find ~/Pictures -type f | shuf -n 1); ACTION=$(notify-send \"Test notification with body image\" \"This notification should contain your user account image and Discord icon. Oh and here is a random image in your Pictures folder: \\\"Testing\" -a \"Hyprland\" -p -h \"string:image-path:/var/lib/AccountsService/icons/$USER\" -t 6000 -i \"discord\" -A \"openImage=Profile image\" -A \"action2=Open the random image\" -A \"action3=Useless button\"); [[ $ACTION == *openImage ]] && xdg-open \"/var/lib/AccountsService/icons/$USER\"; [[ $ACTION == *action2 ]] && xdg-open \"$RANDOM_IMAGE\"'") -) -- # [hidden] + "bash -c 'RANDOM_IMAGE=$(find ~/Pictures -type f | shuf -n 1); ACTION=$(notify-send \"Test notification with body image\" \"This notification should contain your user account image and Discord icon. Oh and here is a random image in your Pictures folder: \\\"Testing\" -a \"Hyprland\" -p -h \"string:image-path:/var/lib/AccountsService/icons/$USER\" -t 6000 -i \"discord\" -A \"openImage=Profile image\" -A \"action2=Open the random image\" -A \"action3=Useless button\"); [[ $ACTION == *openImage ]] && xdg-open \"/var/lib/AccountsService/icons/$USER\"; [[ $ACTION == *action2 ]] && xdg-open \"$RANDOM_IMAGE\"'") +) -- # [hidden] hl.bind("SUPER + ALT + F12", hl.dsp.exec_cmd( - "bash -c 'RANDOM_IMAGE=$(find ~/Pictures -type f | shuf -n 1); ACTION=$(notify-send \"Test notification\" \"This notification should contain a random image in your Pictures folder and Discord icon.\nFlick right to dismiss!\" -a \"Discord (fake)\" -p -h \"string:image-path:$RANDOM_IMAGE\" -t 6000 -i \"discord\" -A \"openImage=Profile image\" -A \"action2=Useless button\"); [[ $ACTION == *openImage ]] && xdg-open \"/var/lib/AccountsService/icons/$USER\"'") -) -- # [hidden] + "bash -c 'RANDOM_IMAGE=$(find ~/Pictures -type f | shuf -n 1); ACTION=$(notify-send \"Test notification\" \"This notification should contain a random image in your Pictures folder and Discord icon.\nFlick right to dismiss!\" -a \"Discord (fake)\" -p -h \"string:image-path:$RANDOM_IMAGE\" -t 6000 -i \"discord\" -A \"openImage=Profile image\" -A \"action2=Useless button\"); [[ $ACTION == *openImage ]] && xdg-open \"/var/lib/AccountsService/icons/$USER\"'") +) -- # [hidden] hl.bind("SUPER + ALT + Equal", - hl.dsp.exec_cmd("notify-send 'Urgent notification' 'Ah hell no' -u critical -a 'Hyprland keybind'")) -- # [hidden] + hl.dsp.exec_cmd("notify-send 'Urgent notification' 'Ah hell no' -u critical -a 'Hyprland keybind'")) -- # [hidden] --##! Session -hl.bind("SUPER + L", hl.dsp.exec_cmd("loginctl lock-session"), { description = "Misc: Lock" }) +hl.bind("SUPER + L", hl.dsp.exec_cmd("loginctl lock-session"), { description = "Session: Lock" }) hl.bind("SUPER + SHIFT + L", hl.dsp.exec_cmd("systemctl suspend || loginctl suspend"), - { locked = true, description = "Misc: Suspend system" }) -- Sleep + { locked = true, description = "Session: Sleep" }) -- Sleep -- hl.bind("switch:on:Lid Switch", hl.dsp.exec_cmd("systemctl suspend || loginctl suspend"), {locked = true} ) -- # [hidden] Suspend when laptop lid is closed, uncomment if for whatever reason it's not the default behavior hl.bind("CTRL + SHIFT + ALT + SUPER + Delete", hl.dsp.exec_cmd("systemctl poweroff || loginctl poweroff"), - { description = "Misc: Shutdown" }) -- # [hidden] Power off + { description = "Session: Shut down" }) -- # [hidden] Power off ---##! Screen ---# Zoom -local function zoomfunction(value) - local zoomvalue = hl.get_config("cursor:zoom_factor") - if (zoomvalue + value) > 3.0 then - hl.config({ cursor = { zoom_factor = 3.0 } }) - elseif (zoomvalue + value) < 1.0 then - hl.config({ cursor = { zoom_factor = 1.0 } }) - else - hl.config({ cursor = { zoom_factor = zoomvalue + value } }) - end -end -hl.bind("SUPER + Minus", function() zoomfunction(-0.3) end, { repeating = true, description = "Misc: Zoom out" }) -hl.bind("SUPER + Equal", function() zoomfunction(0.3) end, { repeating = true, description = "Misc: Zoom in" }) ---# Zoom with keypad -hl.bind("SUPER + code:82", function() zoomfunction(-0.3) end, { repeating = true }) -hl.bind("SUPER + code:86", function() zoomfunction(0.3) end, { repeating = true }) - ---##! Media -local mediaNextCommand = -"playerctl next || playerctl position `bc <<< \"100 * $(playerctl metadata mpris:length) / 1000000 / 100\"`" -hl.bind("SUPER + SHIFT + N", hl.dsp.exec_cmd(mediaNextCommand), { locked = true, description = "Misc: Next track" }) -hl.bind("XF86AudioNext", hl.dsp.exec_cmd(mediaNextCommand), { locked = true }) -hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) -hl.bind("SUPER + SHIFT + ALT + mouse:275", hl.dsp.exec_cmd("playerctl previous")) -hl.bind("SUPER + SHIFT + ALT + mouse:276", hl.dsp.exec_cmd(mediaNextCommand)) -hl.bind("SUPER + SHIFT + B", hl.dsp.exec_cmd("playerctl previous"), { locked = true, description = "Misc: Previous track" }) -hl.bind("SUPER + SHIFT + P", hl.dsp.exec_cmd("playerctl play-pause"), - { locked = true, description = "Misc: Play/pause media" }) -hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SINK@ toggle"), { locked = true }) -hl.bind("SUPER + SHIFT + M", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SINK@ toggle"), - { locked = true, description = "Misc: Toggle mute" }) -hl.bind("ALT + XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), { locked = true }) -hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), { locked = true }) -hl.bind("SUPER + ALT + M", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_SOURCE@ toggle"), - { locked = true, description = "Misc: Toggle mic" }) --##! Apps hl.bind("SUPER + Return", hl.dsp.exec_cmd(terminal), { description = "App: Terminal" }) hl.bind("SUPER + T", hl.dsp.exec_cmd(terminal)) diff --git a/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybinds.qml b/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybinds.qml index 62d51333a..337230aba 100644 --- a/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybinds.qml +++ b/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybinds.qml @@ -16,6 +16,7 @@ Item { StyledFlickable { id: flickable + clip: true anchors.fill: parent anchors.margins: Appearance.rounding.small contentHeight: height @@ -34,4 +35,10 @@ Item { } } } + + ScrollEdgeFade { + target: flickable + vertical: false + color: Appearance.colors.colLayer0Base + } } diff --git a/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybindsCategory.qml b/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybindsCategory.qml index cb58ba4ca..724daee54 100644 --- a/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybindsCategory.qml +++ b/dots/.config/quickshell/ii/modules/ii/cheatsheet/CheatsheetKeybindsCategory.qml @@ -8,6 +8,8 @@ import QtQuick import QtQuick.Layouts import Quickshell +// Notes: +// We deal with keybinds being numbered 1, 2, etc by discarding 2+, keeping 1 and replacing it with a generic "" Column { id: root required property string categoryName @@ -61,11 +63,11 @@ Column { property var keyBlacklist: ["SUPER_L", "SUPER_R"] property var keySubstitutions: Object.assign({ "Super": "", - "Mouse_up": "Scroll ↓", // ikr, weird - "Mouse_down": "Scroll ↑", // trust me bro - "Mouse:272": "LMB", - "Mouse:273": "RMB", - "Mouse:275": "MouseBack", + "mouse_up": "Scroll ↓", // ikr, weird + "mouse_down": "Scroll ↑", // trust me bro + "mouse:272": "LMB", + "mouse:273": "RMB", + "mouse:275": "MouseBack", "Slash": "/", "Hash": "#", "Return": "Enter", @@ -93,6 +95,7 @@ Column { return list; } + visible: repeater.model.length > 0 spacing: titleSpacing StyledText { @@ -100,14 +103,59 @@ Column { font.pixelSize: Appearance.font.pixelSize.title } + function hasDescription(bind) { + return bind.description?.length > 0; + } + + function isCategory(bind, categoryName) { + return bind.description.substring(0, bind.description.indexOf(":")) === categoryName; + } + + function isUncategorized(bind) { + return bind.description.indexOf(":") === -1; + } + + function containsNonFirstRepetitive(bind) { + const key = bind.key; + if (key.includes("mouse") || key.includes("page")) return false; + // Contains non-1 number + if (/\d/.test(key) && !key.includes("1")) return true; + // Contains non-left direction + if (/^(right|up|down)\b/i.test(key)) return true; + return false; + } + + function containsFirstRepetitive(bind) { + const key = bind.key; + return key.includes("1") || /left/i.test(key); + } + + function transformKey(key) { + const replaced = root.keySubstitutions[key] || key; + const denumbered = replaced.replace("1", ""); + const dedirectioned = denumbered.replace("Left", ""); + return dedirectioned; + } + + function transformDescription(bind, categoryName) { + const description = bind.description + const regex = new RegExp("\\s*" + categoryName + "\\s*:\\s*"); + const decategorized = description.replace(regex, ""); + if (!containsFirstRepetitive(bind)) return decategorized; + const denumbered = decategorized.replace("1", ""); + const dedirectioned = denumbered.replace(/ \b(left|right|up|down)\b/i, " "); + return dedirectioned; + } + Column { spacing: 4 Repeater { + id: repeater model: { if (!root.isCategorized) { - return HyprlandKeybinds.keybinds.filter(bind => bind.description?.length > 0 && bind.description.indexOf(":") === -1); + return HyprlandKeybinds.keybinds.filter(bind => root.hasDescription(bind) && root.isUncategorized(bind) && !root.containsNonFirstRepetitive(bind)); } - return HyprlandKeybinds.keybinds.filter(bind => bind.description?.length > 0 && bind.description.substring(0, bind.description.indexOf(":")) === root.categoryName); + return HyprlandKeybinds.keybinds.filter(bind => root.hasDescription(bind) && root.isCategory(bind, root.categoryName) && !root.containsNonFirstRepetitive(bind)); } delegate: BindLine { required property var modelData @@ -138,7 +186,7 @@ Column { } delegate: KeyboardKey { required property var modelData - key: modelData + key: root.transformKey(modelData) pixelSize: Config.options.cheatsheet.fontSize.key } } @@ -152,10 +200,7 @@ Column { id: keybindKey anchors.verticalCenter: parent.verticalCenter visible: !keyBlacklist.includes(bindLine.keyData.key) - key: { - const k = StringUtils.toTitleCase(bindLine.keyData.key) - return root.keySubstitutions[k] || k - } + key: root.transformKey(bindLine.keyData.key) pixelSize: Config.options.cheatsheet.fontSize.key color: Appearance.colors.colOnLayer0 } @@ -169,10 +214,7 @@ Column { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left font.pixelSize: Config.options.cheatsheet.fontSize.comment || Appearance.font.pixelSize.smaller - text: { - const regex = new RegExp("\\s*" + bindLine.categoryName + "\\s*:\\s*"); - return bindLine.keyData.description.replace(regex, ""); - } + text: root.transformDescription(bindLine.keyData, bindLine.categoryName) } } }