2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | Dmenu (Rofi) Commands
|
|
|
|
|
2020-04-01 20:17:47 -04:00
|
|
|
module XMonad.Internal.Command.DMenu
|
|
|
|
( runCmdMenu
|
|
|
|
, runAppMenu
|
|
|
|
, runClipMenu
|
|
|
|
, runWinMenu
|
|
|
|
, runNetMenu
|
|
|
|
, runDevMenu
|
2020-05-02 00:02:29 -04:00
|
|
|
, runBwMenu
|
2021-12-15 00:30:18 -05:00
|
|
|
, runVPNMenu
|
2021-11-29 00:56:16 -05:00
|
|
|
, runBTMenu
|
2020-04-01 20:17:47 -04:00
|
|
|
, runShowKeys
|
2020-08-17 18:46:02 -04:00
|
|
|
, runAutorandrMenu
|
2020-04-01 20:17:47 -04:00
|
|
|
) where
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-22 01:28:46 -04:00
|
|
|
-- import Control.Monad.Reader
|
2020-03-28 14:44:50 -04:00
|
|
|
|
|
|
|
import Graphics.X11.Types
|
|
|
|
|
2021-11-07 13:35:08 -05:00
|
|
|
import System.Directory (XdgDirectory (..), getXdgDirectory)
|
2022-06-22 01:28:46 -04:00
|
|
|
-- import System.IO
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2021-11-07 13:35:08 -05:00
|
|
|
import XMonad.Core hiding (spawn)
|
|
|
|
import XMonad.Internal.Dependency
|
2022-06-22 01:28:46 -04:00
|
|
|
-- import XMonad.Internal.Notify
|
|
|
|
-- import XMonad.Internal.Process
|
2021-11-21 10:26:28 -05:00
|
|
|
import XMonad.Internal.Shell
|
2020-03-28 14:44:50 -04:00
|
|
|
import XMonad.Util.NamedActions
|
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2021-06-19 00:17:47 -04:00
|
|
|
-- | DMenu executables
|
2020-04-01 22:06:00 -04:00
|
|
|
|
2020-03-28 14:44:50 -04:00
|
|
|
myDmenuCmd :: String
|
|
|
|
myDmenuCmd = "rofi"
|
|
|
|
|
2021-06-19 00:17:47 -04:00
|
|
|
myDmenuDevices :: String
|
|
|
|
myDmenuDevices = "rofi-dev"
|
|
|
|
|
|
|
|
myDmenuPasswords :: String
|
|
|
|
myDmenuPasswords = "rofi-bw"
|
|
|
|
|
2021-11-29 00:56:16 -05:00
|
|
|
myDmenuBluetooth :: String
|
|
|
|
myDmenuBluetooth = "rofi-bt"
|
|
|
|
|
2021-12-15 00:30:18 -05:00
|
|
|
myDmenuVPN :: String
|
|
|
|
myDmenuVPN = "rofi-evpn"
|
|
|
|
|
2021-06-19 00:17:47 -04:00
|
|
|
myDmenuMonitors :: String
|
|
|
|
myDmenuMonitors = "rofi-autorandr"
|
|
|
|
|
|
|
|
myDmenuNetworks :: String
|
|
|
|
myDmenuNetworks = "networkmanager_dmenu"
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | Other internal functions
|
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
spawnDmenuCmd :: String -> [String] -> SometimesX
|
|
|
|
spawnDmenuCmd n = sometimesExeArgs n True myDmenuCmd
|
2020-04-01 22:06:00 -04:00
|
|
|
|
2020-08-15 17:00:13 -04:00
|
|
|
themeArgs :: String -> [String]
|
|
|
|
themeArgs hexColor =
|
|
|
|
[ "-theme-str"
|
|
|
|
, "'#element.selected.normal { background-color: " ++ hexColor ++ "; }'"
|
|
|
|
]
|
|
|
|
|
|
|
|
myDmenuMatchingArgs :: [String]
|
|
|
|
myDmenuMatchingArgs = ["-i"] -- case insensitivity
|
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | Exported Commands
|
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runDevMenu :: SometimesX
|
2022-06-26 19:05:25 -04:00
|
|
|
runDevMenu = sometimesIO "device manager" (Only_ $ localExe myDmenuDevices) $ do
|
2021-06-19 00:17:47 -04:00
|
|
|
c <- io $ getXdgDirectory XdgConfig "rofi/devices.yml"
|
|
|
|
spawnCmd myDmenuDevices
|
|
|
|
$ ["-c", c]
|
|
|
|
++ "--" : themeArgs "#999933"
|
|
|
|
++ myDmenuMatchingArgs
|
2020-05-02 00:02:29 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runBTMenu :: SometimesX
|
|
|
|
runBTMenu = sometimesExeArgs "bluetooth selector" False myDmenuBluetooth
|
2021-11-29 00:56:16 -05:00
|
|
|
$ "-c":themeArgs "#0044bb"
|
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runBwMenu :: SometimesX
|
2022-06-26 19:05:25 -04:00
|
|
|
runBwMenu = sometimesIO "password manager" (Only_ $ localExe myDmenuPasswords) $
|
2021-09-05 12:22:16 -04:00
|
|
|
spawnCmd myDmenuPasswords $ ["-c"] ++ themeArgs "#bb6600" ++ myDmenuMatchingArgs
|
2020-05-02 00:02:29 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runVPNMenu :: SometimesX
|
2022-06-26 19:05:25 -04:00
|
|
|
runVPNMenu = sometimesIO "VPN selector" (Only_ $ localExe myDmenuVPN) $
|
2021-12-15 00:30:18 -05:00
|
|
|
spawnCmd myDmenuVPN $ ["-c"] ++ themeArgs "#007766" ++ myDmenuMatchingArgs
|
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
-- runShowKeys :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
|
|
|
|
-- runShowKeys x = addName "Show Keybindings" $ do
|
|
|
|
-- s <- io $ evalFeature $ runDMenuShowKeys x
|
|
|
|
-- ifSatisfied s
|
|
|
|
-- $ spawnNotify
|
|
|
|
-- $ defNoteError { body = Just $ Text "could not display keymap" }
|
|
|
|
|
|
|
|
-- TODO not sure what to do with this yet
|
2020-03-28 14:44:50 -04:00
|
|
|
runShowKeys :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
|
2022-06-21 00:56:42 -04:00
|
|
|
runShowKeys _ = NamedAction (skip :: (X ()))
|
|
|
|
-- addName "Show Keybindings" $ evalAlways $ runDMenuShowKeys x
|
2021-06-20 13:55:31 -04:00
|
|
|
|
2022-06-22 01:28:46 -04:00
|
|
|
-- runDMenuShowKeys :: [((KeyMask, KeySym), NamedAction)] -> AlwaysX
|
|
|
|
-- runDMenuShowKeys kbs =
|
|
|
|
-- Option (runDMenuShowKeys' kbs) (Always runNotifyShowKeys)
|
|
|
|
|
|
|
|
-- runNotifyShowKeys :: X ()
|
|
|
|
-- runNotifyShowKeys = spawnNotify
|
|
|
|
-- $ defNoteError { body = Just $ Text "could not display keymap" }
|
|
|
|
|
|
|
|
-- runDMenuShowKeys' :: [((KeyMask, KeySym), NamedAction)] -> Subfeature (X ()) Tree
|
|
|
|
-- runDMenuShowKeys' kbs = Subfeature
|
|
|
|
-- { sfName = "keyboard shortcut menu"
|
|
|
|
-- , sfTree = IOTree (Standalone act) deps
|
|
|
|
-- , sfLevel = Warn
|
|
|
|
-- }
|
|
|
|
-- where
|
|
|
|
-- deps = Only $ Executable True myDmenuCmd
|
|
|
|
-- act = io $ do
|
|
|
|
-- (h, _, _, _) <- createProcess' $ (shell' cmd) { std_in = CreatePipe }
|
|
|
|
-- forM_ h $ \h' -> hPutStr h' (unlines $ showKm kbs) >> hClose h'
|
|
|
|
-- cmd = fmtCmd myDmenuCmd $ ["-dmenu", "-p", "commands"]
|
|
|
|
-- ++ themeArgs "#7f66ff" ++ myDmenuMatchingArgs
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runCmdMenu :: SometimesX
|
2021-11-20 19:35:24 -05:00
|
|
|
runCmdMenu = spawnDmenuCmd "command menu" ["-show", "run"]
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runAppMenu :: SometimesX
|
2021-11-20 19:35:24 -05:00
|
|
|
runAppMenu = spawnDmenuCmd "app launcher" ["-show", "drun"]
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runClipMenu :: SometimesX
|
|
|
|
runClipMenu = sometimesIO "clipboard manager" deps act
|
2021-06-22 00:01:07 -04:00
|
|
|
where
|
2022-06-21 00:56:42 -04:00
|
|
|
act = spawnCmd myDmenuCmd args
|
2022-06-26 19:05:25 -04:00
|
|
|
deps = toAnd (sysExe myDmenuCmd) (sysExe "greenclip")
|
2021-06-22 00:01:07 -04:00
|
|
|
args = [ "-modi", "\"clipboard:greenclip print\""
|
|
|
|
, "-show", "clipboard"
|
|
|
|
, "-run-command", "'{cmd}'"
|
|
|
|
] ++ themeArgs "#00c44e"
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runWinMenu :: SometimesX
|
2021-11-20 19:35:24 -05:00
|
|
|
runWinMenu = spawnDmenuCmd "window switcher" ["-show", "window"]
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runNetMenu :: SometimesX
|
2021-11-20 19:35:24 -05:00
|
|
|
runNetMenu =
|
2022-06-21 00:56:42 -04:00
|
|
|
sometimesExeArgs "network control menu" True myDmenuNetworks $ themeArgs "#ff3333"
|
2020-08-17 18:46:02 -04:00
|
|
|
|
2022-06-21 00:56:42 -04:00
|
|
|
runAutorandrMenu :: SometimesX
|
2021-11-20 19:35:24 -05:00
|
|
|
runAutorandrMenu =
|
2022-06-21 00:56:42 -04:00
|
|
|
sometimesExeArgs "autorandr menu" True myDmenuMonitors $ themeArgs "#ff0066"
|