REF make rofi code neater
This commit is contained in:
parent
3b9b98a1f6
commit
63b4f5b564
|
@ -342,10 +342,17 @@ runCalc = spawnCmd myTerm ["-e", "R"]
|
||||||
myDmenuCmd :: String
|
myDmenuCmd :: String
|
||||||
myDmenuCmd = "rofi"
|
myDmenuCmd = "rofi"
|
||||||
|
|
||||||
-- TODO simplify the convoluted garbage heap...to be fair, this is
|
-- | Focus rofi on the current workspace always
|
||||||
-- going to be ugly simply because rofi uses xrandr and xmonad uses
|
-- Apparently xrandr and xinerama order monitors differently, which
|
||||||
-- xinerama to get screen information...and apparently these index
|
-- means they have different indices. Since rofi uses the former and
|
||||||
-- differently.
|
-- xmonad uses the latter, this function is to figure out the xrandr
|
||||||
|
-- screen name based on the xinerama screen that is currently in
|
||||||
|
-- focus. The steps to do this:
|
||||||
|
-- 1) get the coordinates of the currently focuses xinerama screen
|
||||||
|
-- 2) get list of Xrandr outputs and filter which ones are connected
|
||||||
|
-- 3) match the coordinates of the xinerama screen with the xrandr
|
||||||
|
-- output and return the latter's name (eg "DP-0") which can be
|
||||||
|
-- fed to Rofi
|
||||||
getMonitorName :: X (Maybe String)
|
getMonitorName :: X (Maybe String)
|
||||||
getMonitorName = do
|
getMonitorName = do
|
||||||
dpy <- asks display
|
dpy <- asks display
|
||||||
|
@ -375,21 +382,25 @@ getMonitorName = do
|
||||||
(Rectangle x y _ _) <- getFocusedScreen
|
(Rectangle x y _ _) <- getFocusedScreen
|
||||||
return (fromIntegral x, fromIntegral y)
|
return (fromIntegral x, fromIntegral y)
|
||||||
|
|
||||||
spawnDmenuCmd :: [String] -> X ()
|
|
||||||
spawnDmenuCmd args = do
|
spawnDmenuCmd :: String -> [String] -> X ()
|
||||||
|
spawnDmenuCmd cmd args = do
|
||||||
name <- getMonitorName
|
name <- getMonitorName
|
||||||
case name of
|
case name of
|
||||||
Just n -> spawnCmd myDmenuCmd $ ["-m", n] ++ args
|
Just n -> spawnCmd cmd $ ["-m", n] ++ args
|
||||||
Nothing -> io $ putStrLn "fail"
|
Nothing -> io $ putStrLn "fail"
|
||||||
|
|
||||||
|
spawnDmenuCmd' :: [String] -> X ()
|
||||||
|
spawnDmenuCmd' = spawnDmenuCmd myDmenuCmd
|
||||||
|
|
||||||
runCmdMenu :: X ()
|
runCmdMenu :: X ()
|
||||||
runCmdMenu = spawnDmenuCmd ["-show", "run"]
|
runCmdMenu = spawnDmenuCmd' ["-show", "run"]
|
||||||
|
|
||||||
runAppMenu :: X ()
|
runAppMenu :: X ()
|
||||||
runAppMenu = spawnDmenuCmd ["-show", "drun"]
|
runAppMenu = spawnDmenuCmd' ["-show", "drun"]
|
||||||
|
|
||||||
runClipMenu :: X ()
|
runClipMenu :: X ()
|
||||||
runClipMenu = spawnDmenuCmd
|
runClipMenu = spawnDmenuCmd'
|
||||||
[ "-modi", "\"clipboard:greenclip print\""
|
[ "-modi", "\"clipboard:greenclip print\""
|
||||||
, "-show", "clipboard"
|
, "-show", "clipboard"
|
||||||
, "-run-command", "'{cmd}'"
|
, "-run-command", "'{cmd}'"
|
||||||
|
@ -397,21 +408,13 @@ runClipMenu = spawnDmenuCmd
|
||||||
]
|
]
|
||||||
|
|
||||||
runWinMenu :: X ()
|
runWinMenu :: X ()
|
||||||
runWinMenu = spawnDmenuCmd ["-show", "window"]
|
runWinMenu = spawnDmenuCmd' ["-show", "window"]
|
||||||
|
|
||||||
runNetMenu :: X ()
|
runNetMenu :: X ()
|
||||||
runNetMenu = do
|
runNetMenu = spawnDmenuCmd "networkmanager_dmenu" []
|
||||||
name <- getMonitorName
|
|
||||||
case name of
|
|
||||||
Just n -> spawnCmd "networkmanager_dmenu" ["-m", n]
|
|
||||||
Nothing -> io $ putStrLn "fail"
|
|
||||||
|
|
||||||
runDevMenu :: X ()
|
runDevMenu :: X ()
|
||||||
runDevMenu = do
|
runDevMenu = spawnDmenuCmd "rofi-devices" []
|
||||||
name <- getMonitorName
|
|
||||||
case name of
|
|
||||||
Just n -> spawnCmd "rofi-devices" ["-m", n]
|
|
||||||
Nothing -> io $ putStrLn "fail"
|
|
||||||
|
|
||||||
runBrowser :: X ()
|
runBrowser :: X ()
|
||||||
runBrowser = spawn "brave"
|
runBrowser = spawn "brave"
|
||||||
|
|
Loading…
Reference in New Issue