From 36ac649b7b64a45fd9c254c58c2f7f36f55e0d33 Mon Sep 17 00:00:00 2001 From: Derek Taylor Date: Fri, 20 May 2022 12:50:08 -0500 Subject: [PATCH] Adding system sounds to XMonad config. --- .xmonad/README.org | 33 ++++++++++++++++++++++++++++++--- .xmonad/xmonad.hs | 18 +++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.xmonad/README.org b/.xmonad/README.org index e248cff..48288e7 100644 --- a/.xmonad/README.org +++ b/.xmonad/README.org @@ -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-", spawn "dm-run") -- Dmenu + , ("M-S-", 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 diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 37aa88b..7d52fe6 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -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-", spawn "dm-run") -- Dmenu + , ("M-S-", 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