ENH (actually) make optimus-manager and emacs deps more robust
This commit is contained in:
parent
936a3b16b8
commit
4eb88d5169
|
@ -143,7 +143,7 @@ runClipMenu :: SometimesX
|
||||||
runClipMenu = sometimesIO_ "clipboard manager" "rofi greenclip" tree act
|
runClipMenu = sometimesIO_ "clipboard manager" "rofi greenclip" tree act
|
||||||
where
|
where
|
||||||
act = spawnCmd myDmenuCmd args
|
act = spawnCmd myDmenuCmd args
|
||||||
tree = listToAnds (processExists myClipboardManager)
|
tree = listToAnds (process myClipboardManager)
|
||||||
$ sysExe <$> [myDmenuCmd, myClipboardManager]
|
$ sysExe <$> [myDmenuCmd, myClipboardManager]
|
||||||
args = [ "-modi", "\"clipboard:greenclip print\""
|
args = [ "-modi", "\"clipboard:greenclip print\""
|
||||||
, "-show", "clipboard"
|
, "-show", "clipboard"
|
||||||
|
|
|
@ -71,6 +71,9 @@ myBrowser = "brave-accel"
|
||||||
myEditor :: String
|
myEditor :: String
|
||||||
myEditor = "emacsclient"
|
myEditor = "emacsclient"
|
||||||
|
|
||||||
|
myEditorServer :: String
|
||||||
|
myEditorServer = "emacs"
|
||||||
|
|
||||||
myMultimediaCtl :: String
|
myMultimediaCtl :: String
|
||||||
myMultimediaCtl = "playerctl"
|
myMultimediaCtl = "playerctl"
|
||||||
|
|
||||||
|
@ -128,7 +131,9 @@ runEditor = sometimesIO_ "text editor" "emacs" tree cmd
|
||||||
where
|
where
|
||||||
cmd = spawnCmd myEditor
|
cmd = spawnCmd myEditor
|
||||||
["-c", "-e", doubleQuote "(select-frame-set-input-focus (selected-frame))"]
|
["-c", "-e", doubleQuote "(select-frame-set-input-focus (selected-frame))"]
|
||||||
tree = Only_ $ sysExe myEditor
|
-- NOTE we could test if the emacs socket exists, but it won't come up
|
||||||
|
-- before xmonad starts, so just check to see if the process has started
|
||||||
|
tree = toAnd_ (sysExe myEditor) $ process myEditorServer
|
||||||
|
|
||||||
runFileManager :: SometimesX
|
runFileManager :: SometimesX
|
||||||
runFileManager = sometimesExe "file browser" "pcmanfm" True "pcmanfm"
|
runFileManager = sometimesExe "file browser" "pcmanfm" True "pcmanfm"
|
||||||
|
|
|
@ -135,14 +135,15 @@ runOptimusPrompt' fb = do
|
||||||
#!&& unwords [myOptimusManager, "--switch", mode, "--no-confirm"]
|
#!&& unwords [myOptimusManager, "--switch", mode, "--no-confirm"]
|
||||||
#!&& "killall xmonad"
|
#!&& "killall xmonad"
|
||||||
|
|
||||||
-- TODO test that the socket is open (/tmp/optimus-manager)
|
|
||||||
runOptimusPrompt :: SometimesX
|
runOptimusPrompt :: SometimesX
|
||||||
runOptimusPrompt = Sometimes "graphics switcher" [s]
|
runOptimusPrompt = Sometimes "graphics switcher" [s]
|
||||||
where
|
where
|
||||||
s = Subfeature { sfData = r, sfName = "optimus manager", sfLevel = Error }
|
s = Subfeature { sfData = r, sfName = "optimus manager", sfLevel = Error }
|
||||||
r = IORoot runOptimusPrompt' t
|
r = IORoot runOptimusPrompt' t
|
||||||
t = And1 (fontTreeAlt T.defFontFamily)
|
t = And1 (fontTreeAlt T.defFontFamily)
|
||||||
$ And_ (Only_ $ sysExe myOptimusManager) (Only_ $ sysExe myPrimeOffload)
|
$ listToAnds (socketExists "optimus-manager" socketName) $ sysExe
|
||||||
|
<$> [myOptimusManager, myPrimeOffload]
|
||||||
|
socketName = (</> "optimus-manager") <$> getTemporaryDirectory
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | Universal power prompt
|
-- | Universal power prompt
|
||||||
|
|
|
@ -68,7 +68,6 @@ module XMonad.Internal.Dependency
|
||||||
, readEthernet
|
, readEthernet
|
||||||
, readWireless
|
, readWireless
|
||||||
, socketExists
|
, socketExists
|
||||||
, processExists
|
|
||||||
|
|
||||||
-- lifting
|
-- lifting
|
||||||
, ioSometimes
|
, ioSometimes
|
||||||
|
@ -95,9 +94,9 @@ module XMonad.Internal.Dependency
|
||||||
, pathR
|
, pathR
|
||||||
, pathRW
|
, pathRW
|
||||||
, pathW
|
, pathW
|
||||||
-- , sysTest
|
|
||||||
, voidResult
|
, voidResult
|
||||||
, voidRead
|
, voidRead
|
||||||
|
, process
|
||||||
|
|
||||||
-- misc
|
-- misc
|
||||||
, shellTest
|
, shellTest
|
||||||
|
@ -352,6 +351,7 @@ data SystemDependency =
|
||||||
Executable Bool FilePath
|
Executable Bool FilePath
|
||||||
| AccessiblePath FilePath Bool Bool
|
| AccessiblePath FilePath Bool Bool
|
||||||
| Systemd UnitType String
|
| Systemd UnitType String
|
||||||
|
| Process String
|
||||||
deriving (Eq, Show, Generic)
|
deriving (Eq, Show, Generic)
|
||||||
|
|
||||||
instance Hashable SystemDependency
|
instance Hashable SystemDependency
|
||||||
|
@ -662,6 +662,8 @@ testSysDependency (Systemd t n) = shellTest cmd msg
|
||||||
where
|
where
|
||||||
msg = unwords ["systemd", unitType t, "unit", singleQuote n, "not found"]
|
msg = unwords ["systemd", unitType t, "unit", singleQuote n, "not found"]
|
||||||
cmd = fmtCmd "systemctl" $ ["--user" | t == UserUnit] ++ ["status", n]
|
cmd = fmtCmd "systemctl" $ ["--user" | t == UserUnit] ++ ["status", n]
|
||||||
|
testSysDependency (Process n) = shellTest (fmtCmd "pidof" [n])
|
||||||
|
$ "Process " ++ singleQuote n ++ " not found"
|
||||||
testSysDependency (AccessiblePath p r w) = permMsg <$> getPermissionsSafe p
|
testSysDependency (AccessiblePath p r w) = permMsg <$> getPermissionsSafe p
|
||||||
where
|
where
|
||||||
testPerm False _ _ = Nothing
|
testPerm False _ _ = Nothing
|
||||||
|
@ -788,14 +790,6 @@ socketExists' getPath = do
|
||||||
where
|
where
|
||||||
toErr = Just . Msg Error
|
toErr = Just . Msg Error
|
||||||
|
|
||||||
processExists :: String -> IODependency_
|
|
||||||
processExists n = IOTest_ ("determine if process " ++ n ++ " is running")
|
|
||||||
$ processExists' n
|
|
||||||
|
|
||||||
processExists' :: String -> IO (Maybe Msg)
|
|
||||||
processExists' n = shellTest (fmtCmd "pidof" [n])
|
|
||||||
$ "Process " ++ singleQuote n ++ " not found"
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | DBus Dependency Testing
|
-- | DBus Dependency Testing
|
||||||
|
|
||||||
|
@ -983,8 +977,8 @@ sysdUser = sysd UserUnit
|
||||||
sysdSystem :: String -> IODependency_
|
sysdSystem :: String -> IODependency_
|
||||||
sysdSystem = sysd SystemUnit
|
sysdSystem = sysd SystemUnit
|
||||||
|
|
||||||
-- sysTest :: String -> IO (Maybe String) -> IODependency_
|
process :: String -> IODependency_
|
||||||
-- sysTest n = IOSystem_ . IOTest n
|
process = IOSystem_ . Process
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | Printing
|
-- | Printing
|
||||||
|
@ -1108,6 +1102,7 @@ dataSysDependency d = first Q $
|
||||||
])
|
])
|
||||||
(Systemd t n) -> ("systemd", [ ("unittype", JSON_Q $ Q $ unitType t)
|
(Systemd t n) -> ("systemd", [ ("unittype", JSON_Q $ Q $ unitType t)
|
||||||
, ("unit", JSON_Q $ Q n)])
|
, ("unit", JSON_Q $ Q n)])
|
||||||
|
(Process n) -> ("process", [("name", JSON_Q $ Q n)])
|
||||||
|
|
||||||
dataDBusDependency :: DBusDependency_ -> DependencyData
|
dataDBusDependency :: DBusDependency_ -> DependencyData
|
||||||
dataDBusDependency d =
|
dataDBusDependency d =
|
||||||
|
|
Loading…
Reference in New Issue