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 --- .zsh_aliases | 4 ++++ xmonad.hs | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/.zsh_aliases b/.zsh_aliases index 1a0ffac..5627844 100644 --- a/.zsh_aliases +++ b/.zsh_aliases @@ -133,3 +133,7 @@ alias xclip='xclip -selection clipboard' pacman-url() { pacman -Si "$1" | grep URL | tr -s ' ' | cut -d ' ' -f 3 } + +grep-kill() { + ps aux | grep "$1" | tr -s ' ' | cut -d ' ' -f 2 | xargs kill +} 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