Adding system sounds to XMonad config.

This commit is contained in:
Derek Taylor 2022-05-20 12:50:08 -05:00
parent d9333bba16
commit 36ac649b7b
2 changed files with 45 additions and 6 deletions

View File

@ -13,6 +13,7 @@
- [[#layouts][Layouts]]
- [[#workspaces][Workspaces]]
- [[#managehook][Managehook]]
- [[#system-sounds][System Sounds]]
- [[#keybindings][Keybindings]]
- [[#main][Main]]
@ -152,6 +153,9 @@ myNormColor = colorBack -- This variable is imported from Colors.THEME
myFocusColor :: String -- Border color of focused windows
myFocusColor = color15 -- This variable is imported from Colors.THEME
mySoundPlayer :: String
mySoundPlayer = "ffplay -nodisp -autoexit " -- The program that will play system sounds
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
#+END_SRC
@ -162,6 +166,7 @@ These are commands we want XMonad to execute on startup, such as running a compo
#+BEGIN_SRC haskell
myStartupHook :: X ()
myStartupHook = do
spawnOnce (mySoundPlayer ++ startupSound)
spawn "killall conky" -- kill current conky on each restart
spawn "killall trayer" -- kill current trayer on each restart
#+END_SRC
@ -171,7 +176,7 @@ myStartupHook = do
spawnOnce "picom"
spawnOnce "nm-applet"
spawnOnce "volumeicon"
spawnOnce "/usr/bin/emacs --daemon" -- emacs daemon for the emacsclient
spawn "/usr/bin/emacs --daemon" -- emacs daemon for the emacsclient
#+END_SRC
We killed any running conky and trayer processes earlier in the autostart, so now we sleep for 2 seconds and then restart conky and trayer.
@ -442,6 +447,26 @@ myManageHook = composeAll
] <+> namedScratchpadManageHook myScratchPads
#+END_SRC
* System Sounds
Available sounds that are part of the default =dtos-sounds= package include:
+ menu-01.mp3
+ menu-02.mp3
+ menu-03.mp3
+ shutdown-01.mp3
+ shutdown-02.mp3
+ shutdown-03.mp3
+ startup-01.mp3
+ startup-02.mp3
+ startup-03.mp3
#+begin_src haskell
soundDir = "/opt/dtos-sounds/" -- The directory that has the sound files
startupSound = soundDir ++ "startup-01.mp3"
shutdownSound = soundDir ++ "shutdown-01.mp3"
dmenuSound = soundDir ++ "menu-01.mp3"
#+end_src
* Keybindings
I am using the Xmonad.Util.EZConfig module which allows keybindings to be written in simpler, emacs-like format. The Super/Windows key is 'M' (the modkey). The ALT key is 'M1'. SHIFT is 'S' and CTR is 'C'.
@ -477,14 +502,16 @@ myKeys =
-- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad
, ("M-S-q", io exitSuccess) -- Quits xmonad
, ("M-S-q", sequence_ [spawn (mySoundPlayer ++ shutdownSound)
, io exitSuccess]) -- Quits xmonad
-- KB_GROUP Get Help
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh") -- Get list of keybindings
, ("M-/", spawn "dtos-help") -- DTOS help/tutorial videos
-- KB_GROUP Run Prompt
, ("M-S-<Return>", spawn "dm-run") -- Dmenu
, ("M-S-<Return>", sequence_ [spawn (mySoundPlayer ++ dmenuSound)
, spawn "dm-run"]) -- Dmenu
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to

View File

@ -108,11 +108,15 @@ myNormColor = colorBack -- This variable is imported from Colors.THEME
myFocusColor :: String -- Border color of focused windows
myFocusColor = color15 -- This variable is imported from Colors.THEME
mySoundPlayer :: String
mySoundPlayer = "ffplay -nodisp -autoexit " -- The program that will play system sounds
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
myStartupHook :: X ()
myStartupHook = do
spawnOnce (mySoundPlayer ++ startupSound)
spawn "killall conky" -- kill current conky on each restart
spawn "killall trayer" -- kill current trayer on each restart
@ -120,7 +124,7 @@ myStartupHook = do
spawnOnce "picom"
spawnOnce "nm-applet"
spawnOnce "volumeicon"
spawnOnce "/usr/bin/emacs --daemon" -- emacs daemon for the emacsclient
spawn "/usr/bin/emacs --daemon" -- emacs daemon for the emacsclient
spawn ("sleep 2 && conky -c $HOME/.config/conky/xmonad/" ++ colorScheme ++ "-01.conkyrc")
spawn ("sleep 2 && trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 " ++ colorTrayer ++ " --height 22")
@ -355,20 +359,28 @@ myManageHook = composeAll
, isFullscreen --> doFullFloat
] <+> namedScratchpadManageHook myScratchPads
soundDir = "/opt/dtos-sounds/" -- The directory that has the sound files
startupSound = soundDir ++ "startup-01.mp3"
shutdownSound = soundDir ++ "shutdown-01.mp3"
dmenuSound = soundDir ++ "menu-01.mp3"
-- START_KEYS
myKeys :: [(String, X ())]
myKeys =
-- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad
, ("M-S-q", io exitSuccess) -- Quits xmonad
, ("M-S-q", sequence_ [spawn (mySoundPlayer ++ shutdownSound)
, io exitSuccess]) -- Quits xmonad
-- KB_GROUP Get Help
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh") -- Get list of keybindings
, ("M-/", spawn "dtos-help") -- DTOS help/tutorial videos
-- KB_GROUP Run Prompt
, ("M-S-<Return>", spawn "dm-run") -- Dmenu
, ("M-S-<Return>", sequence_ [spawn (mySoundPlayer ++ dmenuSound)
, spawn "dm-run"]) -- Dmenu
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to