aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-16 10:21:01 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-16 10:21:01 +0200
commitcb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1 (patch)
tree547d1da5da02d98149e1cb349afa8c9b70fb0445
parent2a8eaf57d0a8090ac10fe011e527774e484c96f9 (diff)
downloaddotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.tar.gz
dotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.tar.bz2
dotfiles-cb9e981c80476a7297ecd7c80ba9cd8eafe0f0d1.zip
Added XMonad confirmation before shutdown and notification on restart
-rw-r--r--.zsh_aliases4
-rw-r--r--xmonad.hs20
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
+}
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 = [ ("<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"
+ ]