From ee3afe7fdd13166648d672595e6b741aade4e8c2 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 2 May 2026 05:29:12 -0700 Subject: [PATCH] Add taffybar omni menu --- dotfiles/config/taffybar/taffybar | 2 +- dotfiles/config/taffybar/taffybar.hs | 62 ++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/dotfiles/config/taffybar/taffybar b/dotfiles/config/taffybar/taffybar index bcb2e5cf..2466750d 160000 --- a/dotfiles/config/taffybar/taffybar +++ b/dotfiles/config/taffybar/taffybar @@ -1 +1 @@ -Subproject commit bcb2e5cfafbe2160522dc713e67a16856198b9c9 +Subproject commit 2466750dfadc584bfa9154e5096f95f1de97c40f diff --git a/dotfiles/config/taffybar/taffybar.hs b/dotfiles/config/taffybar/taffybar.hs index 54bac29b..99f73027 100644 --- a/dotfiles/config/taffybar/taffybar.hs +++ b/dotfiles/config/taffybar/taffybar.hs @@ -572,6 +572,50 @@ wakeupDebugWidget :: TaffyIO Gtk.Widget wakeupDebugWidget = decorateWithClassAndBoxM "wakeup-debug" wakeupDebugWidgetNew +omniMenuItem :: Text -> Text -> Text -> OmniMenuItem +omniMenuItem label iconName command = + OmniMenuItem + { omniMenuItemLabel = label, + omniMenuItemCommand = command, + omniMenuItemIcon = Just iconName, + omniMenuItemTooltip = Just command + } + +omniMenuWidget :: TaffyIO Gtk.Widget +omniMenuWidget = + decorateWithClassAndBoxM "omni-menu" $ do + icon <- + liftIO $ + Gtk.imageNewFromIconName + (Just "system-run") + (fromIntegral $ fromEnum Gtk.IconSizeMenu) + >>= Gtk.toWidget + omniMenuNewWithConfig + (defaultOmniMenuConfig icon) + { omniMenuSections = + [ OmniMenuSection + "Launch" + [ omniMenuItem "App launcher" "view-app-grid-symbolic" "hypr_shell_ui launcher", + omniMenuItem "Run command" "system-run" "hypr_shell_ui run", + omniMenuItem "Terminal" "utilities-terminal" "ghostty --gtk-single-instance=false", + omniMenuItem "Browser" "web-browser" "google-chrome-stable", + omniMenuItem "Emacs" "emacs" "sh -lc 'emacsclient -c -n || emacs'", + omniMenuItem "Window picker" "preferences-system-windows" "hypr_shell_ui window go" + ], + OmniMenuSection + "System" + [ omniMenuItem "Lock" "system-lock-screen" "loginctl lock-session", + omniMenuItem "Toggle screensaver" "video-display" "/home/imalison/dotfiles/dotfiles/lib/bin/hypr-screensaver toggle", + omniMenuItem "Reload WM" "view-refresh" "sh -lc 'hyprctl reload || xmonad --restart || river-xmonad-restart'", + omniMenuItem "Restart taffybar" "view-refresh-symbolic" "/home/imalison/dotfiles/dotfiles/config/taffybar/scripts/taffybar-restart", + omniMenuItem "Logout" "system-log-out" "sh -lc 'hyprctl dispatch exit || riverctl exit'", + omniMenuItem "Suspend" "media-playback-pause" "systemctl suspend", + omniMenuItem "Reboot" "system-reboot" "systemctl reboot", + omniMenuItem "Power off" "system-shutdown" "systemctl poweroff" + ] + ] + } + usageLogoWidget :: FilePath -> Text -> IO Gtk.Widget usageLogoWidget iconFile tooltip = do iconPath <- getUserConfigFile "taffybar" ("icons/" <> iconFile) @@ -656,9 +700,9 @@ sniTrayWidget = do startWidgetsForBackend :: Backend -> [TaffyIO Gtk.Widget] startWidgetsForBackend backend = case backend of - BackendX11 -> [workspacesWidget, layoutWidget, windowsWidget] + BackendX11 -> [omniMenuWidget, workspacesWidget, layoutWidget, windowsWidget] -- These Wayland widgets are Hyprland-specific. - BackendWayland -> [workspacesWidget, windowsWidget] + BackendWayland -> [omniMenuWidget, workspacesWidget, windowsWidget] endWidgetsForHost :: String -> [TaffyIO Gtk.Widget] endWidgetsForHost hostName = @@ -708,15 +752,17 @@ mkSimpleTaffyConfig hostName backend cssFiles = barPadding = if hostName `elem` smallBarHosts then 1 - else if hostName `elem` compactBarHosts - then 2 - else 4, + else + if hostName `elem` compactBarHosts + then 2 + else 4, barHeight = if hostName `elem` smallBarHosts then ScreenRatio $ 1 / 48 - else if hostName `elem` compactBarHosts - then ScreenRatio $ 1 / 40 - else ScreenRatio $ 1 / 33, + else + if hostName `elem` compactBarHosts + then ScreenRatio $ 1 / 40 + else ScreenRatio $ 1 / 33, cssPaths = cssFiles }