From cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 16 Sep 2020 10:21:01 +0200 Subject: Added XMonad confirmation before shutdown and notification on restart --- xmonad.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xmonad.hs') diff --git a/xmonad.hs b/xmonad.hs index 4b7ee10..578868b 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -1,9 +1,15 @@ +import Control.Monad +import Data.List +import System.Exit + + import XMonad import XMonad.Config.Desktop -- Utilities import XMonad.Util.EZConfig (additionalKeysP, additionalKeys) import XMonad.Util.SpawnOnce +import XMonad.Util.Dmenu -- Layouts import XMonad.Layout.NoBorders @@ -44,4 +50,18 @@ myKeys = [ ("", spawn "~/bin/volume-ctl up") , ("M-o", spawn "~/bin/project-open") , ("M-m", spawn "st -e mocp") , ("M-S-d", spawn "notify-send \"$(date +\"%H:%M %A %d/%m/%Y %B\")\"") + , ("M-q", spawn "notify-send Restart" >> spawn restartCmd) + , ("M-S-q", confirm "Are you sure you want to shutdown?" $ io (exitWith ExitSuccess)) ] + +confirm :: String -> X () -> X () +confirm prompt f = do + result <- menuArgs "dmenu" ["-p", prompt] ["yes", "no"] + when (result == "yes") f + +restartCmd :: String +restartCmd = intercalate "; " [ "if type xmonad" + , "then xmonad --recompile && xmonad --restart" + , "else xmessage xmonad not in \\$PATH: \"$PATH\"" + , "fi" + ] -- cgit