ENH move some daemons back into xinit to keep them persistant

This commit is contained in:
Nathan Dwarshuis 2022-07-06 19:27:52 -04:00
parent b4af103dd1
commit e8b7c4afc5
3 changed files with 10 additions and 50 deletions

View File

@ -117,18 +117,7 @@ features = FeatureSet
, fsDynWorkspaces = allDWs' , fsDynWorkspaces = allDWs'
, fsTabbedTheme = tabbedFeature , fsTabbedTheme = tabbedFeature
, fsShowKeys = runShowKeys , fsShowKeys = runShowKeys
, fsDaemons = [ runNetAppDaemon , fsDaemons = [runNetAppDaemon, runAutolock]
, 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
]
} }
evalConf db = do evalConf db = do

View File

@ -13,10 +13,6 @@ module XMonad.Internal.Command.DMenu
, runBTMenu , runBTMenu
, runShowKeys , runShowKeys
, runAutorandrMenu , runAutorandrMenu
-- daemons
, runBwDaemon
, runClipManager
) where ) where
import Control.Monad.Reader import Control.Monad.Reader
@ -108,6 +104,7 @@ runAppMenu = spawnDmenuCmd "app launcher" ["-show", "drun"]
runWinMenu :: SometimesX runWinMenu :: SometimesX
runWinMenu = spawnDmenuCmd "window switcher" ["-show", "window"] runWinMenu = spawnDmenuCmd "window switcher" ["-show", "window"]
-- TODO test that networkManager is actually running
runNetMenu :: SometimesX runNetMenu :: SometimesX
runNetMenu = sometimesExeArgs "network control menu" "rofi NetworkManager" runNetMenu = sometimesExeArgs "network control menu" "rofi NetworkManager"
True myDmenuNetworks $ themeArgs "#ff3333" True myDmenuNetworks $ themeArgs "#ff3333"
@ -119,31 +116,21 @@ runAutorandrMenu = sometimesExeArgs "autorandr menu" "rofi autorandr"
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Password manager -- | 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 :: SometimesX
runBwMenu = sometimesIO_ "password manager" "rofi bitwarden" 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 $ ["-c"] ++ themeArgs "#bb6600" ++ myDmenuMatchingArgs
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Clipboard -- | 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 :: 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 = toAnd_ (sysExe myDmenuCmd) $ IOSometimes_ runClipManager -- TODO test that greenclip daemon is actually running
tree = toAnd_ (sysExe myDmenuCmd) $ sysExe myClipboardManager
args = [ "-modi", "\"clipboard:greenclip print\"" args = [ "-modi", "\"clipboard:greenclip print\""
, "-show", "clipboard" , "-show", "clipboard"
, "-run-command", "'{cmd}'" , "-run-command", "'{cmd}'"

View File

@ -36,8 +36,6 @@ module XMonad.Internal.Command.Desktop
-- daemons -- daemons
, runNetAppDaemon , runNetAppDaemon
, runFlameshotDaemon
, runNotificationDaemon
) where ) where
import Control.Monad (void) import Control.Monad (void)
@ -86,9 +84,6 @@ myImageBrowser = "feh"
myNotificationCtrl :: String myNotificationCtrl :: String
myNotificationCtrl = "dunstctl" myNotificationCtrl = "dunstctl"
myNotificationDaemon :: String
myNotificationDaemon = "dunst"
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Misc constants -- | Misc constants
@ -180,17 +175,11 @@ runVolumeMute = featureSound "mute" volumeChangeSound (void toggleMute) $ return
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Notification control -- | Notification control
runNotificationDaemon :: Sometimes (IO ProcessHandle) -- TODO test that dunst is actually running
runNotificationDaemon = sometimesIO_ "notification daemon" "dunst" tree cmd
where
tree = Only_ $ sysExe myNotificationDaemon
cmd = snd <$> spawnPipe myNotificationDaemon
runNotificationCmd :: String -> FilePath -> SometimesX runNotificationCmd :: String -> FilePath -> SometimesX
runNotificationCmd n arg = sometimesIO_ (n ++ " control") "dunstctl" tree cmd runNotificationCmd n arg = sometimesIO_ (n ++ " control") "dunstctl" tree cmd
where where
tree = And_ (Only_ $ IOSometimes_ runNotificationDaemon) tree = Only_ $ sysExe myNotificationCtrl
(Only_ $ sysExe myNotificationCtrl)
cmd = spawnCmd myNotificationCtrl [arg] cmd = spawnCmd myNotificationCtrl [arg]
runNotificationClose :: SometimesX runNotificationClose :: SometimesX
@ -291,15 +280,10 @@ getCaptureDir = do
where where
fallback = (</> ".local/share") <$> getHomeDirectory fallback = (</> ".local/share") <$> getHomeDirectory
runFlameshotDaemon :: Sometimes (IO ProcessHandle) -- TODO test that flameshot is actually running
runFlameshotDaemon = sometimesIO_ "screen capture daemon" "flameshot" tree cmd
where
tree = Only_ $ sysExe myCapture
cmd = snd <$> (spawnPipe' $ (shell myCapture) { std_err = NoStream })
runFlameshot :: String -> String -> SometimesX runFlameshot :: String -> String -> SometimesX
runFlameshot n mode = sometimesIO_ n myCapture 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 -- TODO this will steal focus from the current window (and puts it
-- in the root window?) ...need to fix -- in the root window?) ...need to fix