diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-16 10:21:01 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-16 10:21:01 +0200 |
| commit | cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1 (patch) | |
| tree | 547d1da5da02d98149e1cb349afa8c9b70fb0445 | |
| parent | 2a8eaf57d0a8090ac10fe011e527774e484c96f9 (diff) | |
| download | dotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.tar.gz dotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.tar.bz2 dotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.zip | |
Added XMonad confirmation before shutdown and notification on restart
| -rw-r--r-- | .zsh_aliases | 4 | ||||
| -rw-r--r-- | xmonad.hs | 20 |
2 files changed, 24 insertions, 0 deletions
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 +} @@ -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 = [ ("<XF86AudioRaiseVolume>", 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" + ] |
