From e8b7c4afc52f5789b222725efbf855ce5b7077dc Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Wed, 6 Jul 2022 19:27:52 -0400 Subject: [PATCH] ENH move some daemons back into xinit to keep them persistant --- bin/xmonad.hs | 13 +------------ lib/XMonad/Internal/Command/DMenu.hs | 23 +++++------------------ lib/XMonad/Internal/Command/Desktop.hs | 24 ++++-------------------- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/bin/xmonad.hs b/bin/xmonad.hs index d3b2a93..99318a1 100644 --- a/bin/xmonad.hs +++ b/bin/xmonad.hs @@ -117,18 +117,7 @@ features = FeatureSet , fsDynWorkspaces = allDWs' , fsTabbedTheme = tabbedFeature , fsShowKeys = runShowKeys - , fsDaemons = [ runNetAppDaemon - , runFlameshotDaemon - -- TODO the problem with launching - -- dunst here is that the history - -- will get nuked on each restart - , runNotificationDaemon - , runBwDaemon - -- TODO does this have a lag when - -- spawned within the WM? - , runClipManager - , runAutolock - ] + , fsDaemons = [runNetAppDaemon, runAutolock] } evalConf db = do diff --git a/lib/XMonad/Internal/Command/DMenu.hs b/lib/XMonad/Internal/Command/DMenu.hs index cde4264..ff4eda7 100644 --- a/lib/XMonad/Internal/Command/DMenu.hs +++ b/lib/XMonad/Internal/Command/DMenu.hs @@ -13,10 +13,6 @@ module XMonad.Internal.Command.DMenu , runBTMenu , runShowKeys , runAutorandrMenu - - -- daemons - , runBwDaemon - , runClipManager ) where import Control.Monad.Reader @@ -108,6 +104,7 @@ runAppMenu = spawnDmenuCmd "app launcher" ["-show", "drun"] runWinMenu :: SometimesX runWinMenu = spawnDmenuCmd "window switcher" ["-show", "window"] +-- TODO test that networkManager is actually running runNetMenu :: SometimesX runNetMenu = sometimesExeArgs "network control menu" "rofi NetworkManager" True myDmenuNetworks $ themeArgs "#ff3333" @@ -119,31 +116,21 @@ runAutorandrMenu = sometimesExeArgs "autorandr menu" "rofi autorandr" -------------------------------------------------------------------------------- -- | Password manager -runBwDaemon :: Sometimes (IO ProcessHandle) -runBwDaemon = sometimesIO_ "password manager daemon" "rofi bitwarden" tree cmd - where - tree = Only_ $ localExe myDmenuPasswords - cmd = snd <$> spawnPipeArgs "rofi-bw" ["-d", "3600"] - runBwMenu :: SometimesX runBwMenu = sometimesIO_ "password manager" "rofi bitwarden" - (Only_ $ IOSometimes_ runBwDaemon) $ spawnCmd myDmenuPasswords + -- TODO test that this program is actually running (query the DBus?) + (Only_ $ localExe myDmenuPasswords) $ spawnCmd myDmenuPasswords $ ["-c"] ++ themeArgs "#bb6600" ++ myDmenuMatchingArgs -------------------------------------------------------------------------------- -- | Clipboard -runClipManager :: Sometimes (IO ProcessHandle) -runClipManager = sometimesIO_ "clipboard daemon" "greenclip" tree cmd - where - tree = Only_ $ sysExe myClipboardManager - cmd = snd <$> spawnPipeArgs "greenclip" ["daemon"] - runClipMenu :: SometimesX runClipMenu = sometimesIO_ "clipboard manager" "rofi greenclip" tree act where act = spawnCmd myDmenuCmd args - tree = toAnd_ (sysExe myDmenuCmd) $ IOSometimes_ runClipManager + -- TODO test that greenclip daemon is actually running + tree = toAnd_ (sysExe myDmenuCmd) $ sysExe myClipboardManager args = [ "-modi", "\"clipboard:greenclip print\"" , "-show", "clipboard" , "-run-command", "'{cmd}'" diff --git a/lib/XMonad/Internal/Command/Desktop.hs b/lib/XMonad/Internal/Command/Desktop.hs index 05c8818..9d45df0 100644 --- a/lib/XMonad/Internal/Command/Desktop.hs +++ b/lib/XMonad/Internal/Command/Desktop.hs @@ -36,8 +36,6 @@ module XMonad.Internal.Command.Desktop -- daemons , runNetAppDaemon - , runFlameshotDaemon - , runNotificationDaemon ) where import Control.Monad (void) @@ -86,9 +84,6 @@ myImageBrowser = "feh" myNotificationCtrl :: String myNotificationCtrl = "dunstctl" -myNotificationDaemon :: String -myNotificationDaemon = "dunst" - -------------------------------------------------------------------------------- -- | Misc constants @@ -180,17 +175,11 @@ runVolumeMute = featureSound "mute" volumeChangeSound (void toggleMute) $ return -------------------------------------------------------------------------------- -- | Notification control -runNotificationDaemon :: Sometimes (IO ProcessHandle) -runNotificationDaemon = sometimesIO_ "notification daemon" "dunst" tree cmd - where - tree = Only_ $ sysExe myNotificationDaemon - cmd = snd <$> spawnPipe myNotificationDaemon - +-- TODO test that dunst is actually running runNotificationCmd :: String -> FilePath -> SometimesX runNotificationCmd n arg = sometimesIO_ (n ++ " control") "dunstctl" tree cmd where - tree = And_ (Only_ $ IOSometimes_ runNotificationDaemon) - (Only_ $ sysExe myNotificationCtrl) + tree = Only_ $ sysExe myNotificationCtrl cmd = spawnCmd myNotificationCtrl [arg] runNotificationClose :: SometimesX @@ -291,15 +280,10 @@ getCaptureDir = do where fallback = ( ".local/share") <$> getHomeDirectory -runFlameshotDaemon :: Sometimes (IO ProcessHandle) -runFlameshotDaemon = sometimesIO_ "screen capture daemon" "flameshot" tree cmd - where - tree = Only_ $ sysExe myCapture - cmd = snd <$> (spawnPipe' $ (shell myCapture) { std_err = NoStream }) - +-- TODO test that flameshot is actually running runFlameshot :: String -> String -> SometimesX runFlameshot n mode = sometimesIO_ n myCapture - (Only_ $ IOSometimes_ runFlameshotDaemon) $ spawnCmd myCapture [mode] + (Only_ $ sysExe myCapture) $ spawnCmd myCapture [mode] -- TODO this will steal focus from the current window (and puts it -- in the root window?) ...need to fix