[Linux] Don't do anything in rofi_select_input if nothing selected
This commit is contained in:
parent
a5e55df922
commit
fb24509e21
@ -16,11 +16,14 @@ main = do
|
|||||||
matches = catMaybes $ matchRegex sinkRegex <$> sinkInfos
|
matches = catMaybes $ matchRegex sinkRegex <$> sinkInfos
|
||||||
entries = map buildEntry matches
|
entries = map buildEntry matches
|
||||||
rofiText = intercalate "\n" entries
|
rofiText = intercalate "\n" entries
|
||||||
selection <- snd <$> shellStrict "rofi -dmenu -i" (select $ map fromString entries)
|
(exitCode, selection) <- shellStrict "rofi -dmenu -i" (select $ map fromString entries)
|
||||||
|
case exitCode of
|
||||||
|
ExitSuccess -> do
|
||||||
let selectedSink = head $ splitOn " " $ unpack selection
|
let selectedSink = head $ splitOn " " $ unpack selection
|
||||||
mapM_ (setMuteAction "1" . head) matches
|
mapM_ (setMuteAction "1" . head) matches
|
||||||
setMuteAction "0" selectedSink
|
setMuteAction "0" selectedSink
|
||||||
return ()
|
return ()
|
||||||
|
ExitFailure _ -> return ()
|
||||||
where getSinkText = snd <$> shellStrict "pactl list sink-inputs" empty
|
where getSinkText = snd <$> shellStrict "pactl list sink-inputs" empty
|
||||||
sinkRegex = mkRegexWithOpts "Input .([0-9]*).*?application.name =([^\n]*)" False True
|
sinkRegex = mkRegexWithOpts "Input .([0-9]*).*?application.name =([^\n]*)" False True
|
||||||
buildEntry (num:name:_) = let app = (filter (not . (`elem` ("\"" :: String))) name) in printf "%s - %s" num $ trim app
|
buildEntry (num:name:_) = let app = (filter (not . (`elem` ("\"" :: String))) name) in printf "%s - %s" num $ trim app
|
||||||
|
Loading…
Reference in New Issue
Block a user