ENH check for udisks before enabling epic super mario sounds
This commit is contained in:
parent
93215d199d
commit
7981533664
|
@ -1,5 +1,3 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- | Module for monitoring removable drive events
|
-- | Module for monitoring removable drive events
|
||||||
--
|
--
|
||||||
|
@ -16,19 +14,23 @@ import Data.Map.Lazy (Map, member)
|
||||||
import DBus
|
import DBus
|
||||||
import DBus.Client
|
import DBus.Client
|
||||||
|
|
||||||
|
import XMonad.Internal.DBus.Control (pathExists)
|
||||||
import XMonad.Internal.Shell
|
import XMonad.Internal.Shell
|
||||||
|
|
||||||
|
bus :: BusName
|
||||||
|
bus = busName_ "org.freedesktop.UDisks2"
|
||||||
|
|
||||||
path :: ObjectPath
|
path :: ObjectPath
|
||||||
path = "/org/freedesktop/UDisks2"
|
path = objectPath_ "/org/freedesktop/UDisks2"
|
||||||
|
|
||||||
interface :: InterfaceName
|
interface :: InterfaceName
|
||||||
interface = "org.freedesktop.DBus.ObjectManager"
|
interface = interfaceName_ "org.freedesktop.DBus.ObjectManager"
|
||||||
|
|
||||||
memAdded :: MemberName
|
memAdded :: MemberName
|
||||||
memAdded = "InterfacesAdded"
|
memAdded = memberName_ "InterfacesAdded"
|
||||||
|
|
||||||
memRemoved :: MemberName
|
memRemoved :: MemberName
|
||||||
memRemoved = "InterfacesRemoved"
|
memRemoved = memberName_ "InterfacesRemoved"
|
||||||
|
|
||||||
driveInsertedSound :: FilePath
|
driveInsertedSound :: FilePath
|
||||||
driveInsertedSound = "smb_powerup.wav"
|
driveInsertedSound = "smb_powerup.wav"
|
||||||
|
@ -62,8 +64,8 @@ playSoundMaybe p b = when b $ playSound p
|
||||||
-- If it not already, we won't see any signals from the dbus until it is
|
-- If it not already, we won't see any signals from the dbus until it is
|
||||||
-- started (it will work after it is started however). It seems safe to simply
|
-- started (it will work after it is started however). It seems safe to simply
|
||||||
-- enable the udisks2 service at boot; however this is not default behavior.
|
-- enable the udisks2 service at boot; however this is not default behavior.
|
||||||
runRemovableMon :: IO ()
|
listenDevices :: IO ()
|
||||||
runRemovableMon = do
|
listenDevices = do
|
||||||
client <- connectSystem
|
client <- connectSystem
|
||||||
_ <- addMatch' client memAdded driveInsertedSound addedHasDrive
|
_ <- addMatch' client memAdded driveInsertedSound addedHasDrive
|
||||||
_ <- addMatch' client memRemoved driveRemovedSound removedHasDrive
|
_ <- addMatch' client memRemoved driveRemovedSound removedHasDrive
|
||||||
|
@ -71,3 +73,9 @@ runRemovableMon = do
|
||||||
where
|
where
|
||||||
addMatch' client m p f = addMatch client ruleUdisks { matchMember = Just m }
|
addMatch' client m p f = addMatch client ruleUdisks { matchMember = Just m }
|
||||||
$ playSoundMaybe p . f . signalBody
|
$ playSoundMaybe p . f . signalBody
|
||||||
|
|
||||||
|
runRemovableMon :: IO ()
|
||||||
|
runRemovableMon = do
|
||||||
|
e <- pathExists True bus path
|
||||||
|
if e then listenDevices else
|
||||||
|
putStrLn "WARNING: udisks not running. Super Mario disk sounds disabled."
|
||||||
|
|
Loading…
Reference in New Issue