From 4c48d839524b5e72a6589a45e023bd94d7b59061 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 14 May 2026 12:02:52 +0200 Subject: [PATCH] More helpers --- config/hypr/bindings.lua | 26 +++++++++++----------- default/hypr/autostart.lua | 24 ++++++++++---------- default/hypr/bindings/utilities.lua | 34 ++++++++++++++--------------- default/hypr/helpers.lua | 30 ++++++++++++++++++++++++- default/hypr/plain-bindings.lua | 2 +- 5 files changed, 72 insertions(+), 44 deletions(-) diff --git a/config/hypr/bindings.lua b/config/hypr/bindings.lua index bf5761c7..df3a9f95 100644 --- a/config/hypr/bindings.lua +++ b/config/hypr/bindings.lua @@ -2,7 +2,7 @@ o.bind("SUPER + RETURN", "Terminal", "omarchy-launch-terminal") o.bind("SUPER + ALT + RETURN", "Tmux", "omarchy-launch-terminal-tmux") o.bind("SUPER + SHIFT + RETURN", "Browser", "omarchy-launch-browser") -o.bind("SUPER + SHIFT + F", "File manager", o.launch("nautilus --new-window")) +o.bind_launch("SUPER + SHIFT + F", "File manager", "nautilus --new-window") o.bind("SUPER + ALT + SHIFT + F", "File manager (cwd)", "omarchy-launch-nautilus-cwd") o.bind("SUPER + SHIFT + B", "Browser", "omarchy-launch-browser") o.bind("SUPER + SHIFT + ALT + B", "Browser (private)", "omarchy-launch-browser --private") @@ -12,20 +12,20 @@ o.bind("SUPER + SHIFT + N", "Editor", "omarchy-launch-editor") o.bind("SUPER + SHIFT + D", "Docker", "omarchy-launch-tui lazydocker") o.bind("SUPER + SHIFT + G", "Signal", [[omarchy-launch-or-focus ^signal$ "]] .. o.launch("signal-desktop") .. [["]]) o.bind("SUPER + SHIFT + O", "Obsidian", [[omarchy-launch-or-focus ^obsidian$ "]] .. o.launch("obsidian") .. [["]]) -o.bind("SUPER + SHIFT + W", "Typora", o.launch("typora --enable-wayland-ime")) -o.bind("SUPER + SHIFT + SLASH", "Passwords", o.launch("1password")) +o.bind_launch("SUPER + SHIFT + W", "Typora", "typora --enable-wayland-ime") +o.bind_launch("SUPER + SHIFT + SLASH", "Passwords", "1password") -- Web app bindings. -o.bind("SUPER + SHIFT + A", "ChatGPT", o.launch_webapp("https://chatgpt.com")) -o.bind("SUPER + SHIFT + ALT + A", "Grok", o.launch_webapp("https://grok.com")) -o.bind("SUPER + SHIFT + C", "Calendar", o.launch_webapp("https://app.hey.com/calendar/weeks/")) -o.bind("SUPER + SHIFT + E", "Email", o.launch_webapp("https://app.hey.com")) -o.bind("SUPER + SHIFT + Y", "YouTube", o.launch_webapp("https://youtube.com/")) -o.bind("SUPER + SHIFT + ALT + G", "WhatsApp", o.launch_webapp_sole("WhatsApp", "https://web.whatsapp.com/")) -o.bind("SUPER + SHIFT + CTRL + G", "Google Messages", o.launch_webapp_sole("Google Messages", "https://messages.google.com/web/conversations")) -o.bind("SUPER + SHIFT + P", "Google Photos", o.launch_webapp_sole("Google Photos", "https://photos.google.com/")) -o.bind("SUPER + SHIFT + X", "X", o.launch_webapp("https://x.com/")) -o.bind("SUPER + SHIFT + ALT + X", "X Post", o.launch_webapp("https://x.com/compose/post")) +o.bind_webapp("SUPER + SHIFT + A", "ChatGPT", "https://chatgpt.com") +o.bind_webapp("SUPER + SHIFT + ALT + A", "Grok", "https://grok.com") +o.bind_webapp("SUPER + SHIFT + C", "Calendar", "https://app.hey.com/calendar/weeks/") +o.bind_webapp("SUPER + SHIFT + E", "Email", "https://app.hey.com") +o.bind_webapp("SUPER + SHIFT + Y", "YouTube", "https://youtube.com/") +o.bind_webapp_sole("SUPER + SHIFT + ALT + G", "WhatsApp", "https://web.whatsapp.com/") +o.bind_webapp_sole("SUPER + SHIFT + CTRL + G", "Google Messages", "https://messages.google.com/web/conversations") +o.bind_webapp_sole("SUPER + SHIFT + P", "Google Photos", "https://photos.google.com/") +o.bind_webapp("SUPER + SHIFT + X", "X", "https://x.com/") +o.bind_webapp("SUPER + SHIFT + ALT + X", "X Post", "https://x.com/compose/post") -- Add extra bindings below. -- o.bind("SUPER + SHIFT + R", "SSH", "alacritty -e ssh your-server") diff --git a/default/hypr/autostart.lua b/default/hypr/autostart.lua index 24af418f..e56a2e62 100644 --- a/default/hypr/autostart.lua +++ b/default/hypr/autostart.lua @@ -1,16 +1,16 @@ -o.launch_on_start(o.launch("hypridle")) -o.launch_on_start(o.launch("mako")) -o.launch_on_start("! omarchy-toggle-enabled waybar-off && " .. o.launch("waybar")) -o.launch_on_start(o.launch("fcitx5 --disable notificationitem")) -o.launch_on_start(o.launch("swaybg -i ~/.config/omarchy/current/background -m fill")) -o.launch_on_start("/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1") -o.launch_on_start("omarchy-first-run") -o.launch_on_start("omarchy-powerprofiles-init") -o.launch_on_start(o.launch("omarchy-hyprland-monitor-watch")) +o.launch_on_start("hypridle") +o.launch_on_start("mako") +o.exec_on_start("! omarchy-toggle-enabled waybar-off && " .. o.launch("waybar")) +o.launch_on_start("fcitx5 --disable notificationitem") +o.launch_on_start("swaybg -i ~/.config/omarchy/current/background -m fill") +o.exec_on_start("/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1") +o.exec_on_start("omarchy-first-run") +o.exec_on_start("omarchy-powerprofiles-init") +o.launch_on_start("omarchy-hyprland-monitor-watch") -- Slow app launch fix -- set systemd vars. -o.launch_on_start("systemctl --user import-environment $(env | cut -d'=' -f 1)") -o.launch_on_start("dbus-update-activation-environment --systemd --all") +o.exec_on_start("systemctl --user import-environment $(env | cut -d'=' -f 1)") +o.exec_on_start("dbus-update-activation-environment --systemd --all") -- Run post-boot hooks after startup config has loaded. -o.launch_on_start("sleep 2 && omarchy-hook post-boot") +o.exec_on_start("sleep 2 && omarchy-hook post-boot") diff --git a/default/hypr/bindings/utilities.lua b/default/hypr/bindings/utilities.lua index 67d26f2f..a4af2286 100644 --- a/default/hypr/bindings/utilities.lua +++ b/default/hypr/bindings/utilities.lua @@ -1,12 +1,12 @@ o.bind("SUPER + SPACE", "Launch apps", "omarchy-launch-walker") o.bind("SUPER + CTRL + E", "Emoji picker", "omarchy-launch-walker -m symbols") -o.bind("SUPER + CTRL + C", "Capture menu", "omarchy-menu capture") -o.bind("SUPER + CTRL + O", "Toggle menu", "omarchy-menu toggle") -o.bind("SUPER + CTRL + H", "Hardware menu", "omarchy-menu hardware") -o.bind("SUPER + ALT + SPACE", "Omarchy menu", "omarchy-menu") -o.bind("SUPER + SHIFT + code:201", "Omarchy menu", "omarchy-menu") -o.bind("SUPER + ESCAPE", "System menu", "omarchy-menu system") -o.bind("XF86PowerOff", "Power menu", "omarchy-menu system", { locked = true }) +o.bind_menu("SUPER + CTRL + C", "Capture menu", "capture") +o.bind_menu("SUPER + CTRL + O", "Toggle menu", "toggle") +o.bind_menu("SUPER + CTRL + H", "Hardware menu", "hardware") +o.bind_menu("SUPER + ALT + SPACE", "Omarchy menu", nil) +o.bind_menu("SUPER + SHIFT + code:201", "Omarchy menu", nil) +o.bind_menu("SUPER + ESCAPE", "System menu", "system") +o.bind_menu("XF86PowerOff", "Power menu", "system", { locked = true }) o.bind("SUPER + K", "Show key bindings", "omarchy-menu-keybindings") o.bind("SUPER + ALT + K", "Show Tmux key bindings", "omarchy-menu-tmux-keybindings") o.bind("XF86Calculator", "Calculator", "gnome-calculator") @@ -16,8 +16,8 @@ o.bind("SUPER + SHIFT + CTRL + UP", "Move Waybar to top", "omarchy-style-waybar- o.bind("SUPER + SHIFT + CTRL + DOWN", "Move Waybar to bottom", "omarchy-style-waybar-position bottom") o.bind("SUPER + SHIFT + CTRL + LEFT", "Move Waybar to left", "omarchy-style-waybar-position left") o.bind("SUPER + SHIFT + CTRL + RIGHT", "Move Waybar to right", "omarchy-style-waybar-position right") -o.bind("SUPER + CTRL + SPACE", "Background switcher", "omarchy-menu background") -o.bind("SUPER + SHIFT + CTRL + SPACE", "Theme menu", "omarchy-menu theme") +o.bind_menu("SUPER + CTRL + SPACE", "Background switcher", "background") +o.bind_menu("SUPER + SHIFT + CTRL + SPACE", "Theme menu", "theme") o.bind("SUPER + BACKSPACE", "Toggle window transparency", "omarchy-hyprland-window-transparency-toggle") o.bind("SUPER + SHIFT + BACKSPACE", "Toggle window gaps", "omarchy-hyprland-window-gaps-toggle") o.bind("SUPER + CTRL + BACKSPACE", "Toggle single-window square aspect", "omarchy-hyprland-window-single-square-aspect-toggle") @@ -28,29 +28,29 @@ o.bind("SUPER + CTRL + COMMA", "Toggle silencing notifications", "omarchy-toggle o.bind("SUPER + ALT + COMMA", "Invoke last notification", "makoctl invoke") o.bind("SUPER + SHIFT + ALT + COMMA", "Restore last notification", "makoctl restore") -o.bind("SUPER + CTRL + I", "Toggle locking on idle", "omarchy-toggle-idle") -o.bind("SUPER + CTRL + N", "Toggle nightlight", "omarchy-toggle-nightlight") +o.bind_toggle("SUPER + CTRL + I", "Toggle locking on idle", "idle") +o.bind_toggle("SUPER + CTRL + N", "Toggle nightlight", "nightlight") o.bind("SUPER + CTRL + Delete", "Toggle laptop display", "omarchy-hyprland-monitor-internal toggle") o.bind("SUPER + CTRL + ALT + Delete", "Toggle laptop display mirroring", "omarchy-hyprland-monitor-internal-mirror toggle") o.bind("switch:on:Lid Switch", nil, "omarchy-hw-external-monitors && omarchy-hyprland-monitor-internal off", { locked = true }) o.bind("switch:off:Lid Switch", nil, "omarchy-hyprland-monitor-internal on", { locked = true }) o.bind("PRINT", "Screenshot", "omarchy-capture-screenshot") -o.bind("ALT + PRINT", "Screenrecording", "omarchy-menu screenrecord") +o.bind_menu("ALT + PRINT", "Screenrecording", "screenrecord") o.bind("SUPER + PRINT", "Color picker", "pkill hyprpicker || hyprpicker -a") o.bind("SUPER + CTRL + PRINT", "Extract text (OCR) from screenshot", "omarchy-capture-text-extraction") -o.bind("SUPER + CTRL + S", "Share", "omarchy-menu share") +o.bind_menu("SUPER + CTRL + S", "Share", "share") o.bind("SUPER + CTRL + PERIOD", "Transcode", "omarchy-transcode") -o.bind("SUPER + CTRL + R", "Set reminder", "omarchy-menu reminder-set") +o.bind_menu("SUPER + CTRL + R", "Set reminder", "reminder-set") o.bind("SUPER + CTRL + ALT + R", "Show reminders", "omarchy-reminder show") o.bind("SUPER + SHIFT + CTRL + R", "Clear reminders", "omarchy-reminder clear") -o.bind("SUPER + CTRL + ALT + T", "Show time", [[notify-send -u low " $(date +"%A %H:%M · %d %B %Y · Week %V")"]]) -o.bind("SUPER + CTRL + ALT + B", "Show battery remaining", [[notify-send -u low "$(omarchy-battery-status)"]]) -o.bind("SUPER + CTRL + ALT + W", "Show weather", [[notify-send -u low "$(omarchy-weather-status)"]]) +o.bind("SUPER + CTRL + ALT + T", "Show time", "omarchy-notification-time") +o.bind("SUPER + CTRL + ALT + B", "Show battery remaining", "omarchy-notification-battery") +o.bind("SUPER + CTRL + ALT + W", "Show weather", "omarchy-notification-weather") o.bind("SUPER + CTRL + A", "Audio controls", "omarchy-launch-audio") o.bind("SUPER + CTRL + B", "Bluetooth controls", "omarchy-launch-bluetooth") diff --git a/default/hypr/helpers.lua b/default/hypr/helpers.lua index 15c5c3e4..977bc320 100644 --- a/default/hypr/helpers.lua +++ b/default/hypr/helpers.lua @@ -24,12 +24,20 @@ function o.launch(command) return "uwsm-app -- " .. command end -function o.launch_on_start(command) +function o.exec_on_start(command) hl.on("hyprland.start", function() hl.exec_cmd(command) end) end +function o.launch_on_start(command) + o.exec_on_start(o.launch(command)) +end + +function o.bind_launch(keys, description, command, options) + o.bind(keys, description, o.launch(command), options) +end + function o.launch_webapp(url) return "omarchy-launch-webapp " .. shell_quote(url) end @@ -37,3 +45,23 @@ end function o.launch_webapp_sole(name, url) return "omarchy-launch-or-focus-webapp " .. shell_quote(name) .. " " .. shell_quote(url) end + +function o.bind_webapp(keys, description, url, options) + o.bind(keys, description, o.launch_webapp(url), options) +end + +function o.bind_webapp_sole(keys, description, url, options) + o.bind(keys, description, o.launch_webapp_sole(description, url), options) +end + +function o.bind_menu(keys, description, menu, options) + o.bind(keys, description, menu and ("omarchy-menu " .. menu) or "omarchy-menu", options) +end + +function o.bind_toggle(keys, description, toggle, options) + o.bind(keys, description, "omarchy-toggle-" .. toggle, options) +end + +function o.notify(message) + return "notify-send -u low " .. shell_quote(message) +end diff --git a/default/hypr/plain-bindings.lua b/default/hypr/plain-bindings.lua index 2676db3d..1185f643 100644 --- a/default/hypr/plain-bindings.lua +++ b/default/hypr/plain-bindings.lua @@ -6,7 +6,7 @@ require("default.hypr.bindings.utilities") -- Application bindings without Omarchy's preinstalled web apps, TUIs, or desktop apps. o.bind("SUPER + RETURN", "Terminal", "omarchy-launch-terminal") o.bind("SUPER + SHIFT + RETURN", "Browser", "omarchy-launch-browser") -o.bind("SUPER + SHIFT + F", "File manager", o.launch("nautilus --new-window")) +o.bind_launch("SUPER + SHIFT + F", "File manager", "nautilus --new-window") o.bind("SUPER + ALT + SHIFT + F", "File manager (cwd)", "omarchy-launch-nautilus-cwd") o.bind("SUPER + SHIFT + B", "Browser", "omarchy-launch-browser") o.bind("SUPER + SHIFT + ALT + B", "Browser (private)", "omarchy-launch-browser --private")