diff options
| -rw-r--r-- | extras/HOME/.config/rofi/config.rasi | 2 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/bluetooth-select.sh | 6 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/emoji-select.sh | 6 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/emoticon-select.sh | 6 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/rofi-pass | 6 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/set-sink.sh | 6 | ||||
| -rwxr-xr-x | extras/HOME/.local/bin/set-volume.sh | 95 | ||||
| -rw-r--r-- | src/Internal/DMenu.hs | 14 | ||||
| -rw-r--r-- | src/Internal/Keys.hs | 10 | ||||
| -rw-r--r-- | src/Main.hs | 14 |
10 files changed, 154 insertions, 11 deletions
diff --git a/extras/HOME/.config/rofi/config.rasi b/extras/HOME/.config/rofi/config.rasi index 440194b..fe47aa6 100644 --- a/extras/HOME/.config/rofi/config.rasi +++ b/extras/HOME/.config/rofi/config.rasi @@ -8,7 +8,7 @@ alternate-normal-foreground: @theme-color; main-background: #202020f0; - font: "Monofur Bold Nerd Font 34"; + font: "Monofur Nerd Font 24"; } window { diff --git a/extras/HOME/.local/bin/bluetooth-select.sh b/extras/HOME/.local/bin/bluetooth-select.sh index 8c901ee..3a25387 100755 --- a/extras/HOME/.local/bin/bluetooth-select.sh +++ b/extras/HOME/.local/bin/bluetooth-select.sh @@ -1,8 +1,12 @@ #!/bin/bash +if [[ -z "$ROFI" ]] ; then + ROFI='rofi -dmenu' +fi + devices="$(bluetoothctl -- devices | sed 's#^Device ##')" selection="$( - echo -e "$devices\nDisconnect" | rofi -i -p "Connect Bluetooth" \ + echo -e "$devices\nDisconnect" | $ROFI -i -p "Connect Bluetooth" \ -theme-str '* {theme-color: #8888ff;}' \ -dmenu)" diff --git a/extras/HOME/.local/bin/emoji-select.sh b/extras/HOME/.local/bin/emoji-select.sh index 5d244d8..a64a6e9 100755 --- a/extras/HOME/.local/bin/emoji-select.sh +++ b/extras/HOME/.local/bin/emoji-select.sh @@ -1,7 +1,11 @@ #!/bin/bash +if [[ -z "$ROFI" ]] ; then + ROFI='rofi -dmenu' +fi + if ( which rofi ) ; then - menu=(rofi -dmenu -i -p "Select Character" -theme-str '* {theme-color: #ffff88;}' -show run) + menu=($ROFI -i -p "Select Character" -theme-str '* {theme-color: #ffff88;}' -show run) else menu=(dmenu -fn NotoSans:size=24 -i -nf "#ffff88" -sb "#ffff88" -p "Select Character" -l 12 -dim 0.4) fi diff --git a/extras/HOME/.local/bin/emoticon-select.sh b/extras/HOME/.local/bin/emoticon-select.sh index cb593b4..e1637d1 100755 --- a/extras/HOME/.local/bin/emoticon-select.sh +++ b/extras/HOME/.local/bin/emoticon-select.sh @@ -1,7 +1,11 @@ #!/bin/bash +if [[ -z "$ROFI" ]] ; then + ROFI='rofi -dmenu' +fi + if ( which rofi ) ; then - menu=(rofi -i -theme-str '* {theme-color: #ffa050;}' -p "Select Emoticon" -dmenu) + menu=($ROFI -i -theme-str '* {theme-color: #ffa050;}' -p "Select Emoticon") else menu=(dmenu -fn NotoSans:size=24 -i -nf "#ffff88" -sb "#ffff88" -p "Select Emoticon" -l 12 -dim 0.4) fi diff --git a/extras/HOME/.local/bin/rofi-pass b/extras/HOME/.local/bin/rofi-pass index 6eb58b7..d78870a 100755 --- a/extras/HOME/.local/bin/rofi-pass +++ b/extras/HOME/.local/bin/rofi-pass @@ -2,6 +2,10 @@ shopt -s nullglob globstar +if [[ -z "$ROFI" ]] ; then + ROFI='rofi -dmenu' +fi + typeit=0 if [[ $1 == "--type" ]]; then typeit=1 @@ -12,7 +16,7 @@ if [[ -n $WAYLAND_DISPLAY ]]; then dmenu=dmenu-wl xdotool="ydotool type --file -" elif [[ -n $DISPLAY ]]; then - dmenu=(rofi -i -dmenu -p 'Password') + dmenu=($ROFI -i -p 'Password') xdotool="xdotool type --clearmodifiers --file -" else echo "Error: No Wayland or X11 display detected" >&2 diff --git a/extras/HOME/.local/bin/set-sink.sh b/extras/HOME/.local/bin/set-sink.sh index 9cd6f93..cca8746 100755 --- a/extras/HOME/.local/bin/set-sink.sh +++ b/extras/HOME/.local/bin/set-sink.sh @@ -1,6 +1,10 @@ #!/bin/bash -DMENU=(rofi -i -theme-str '* {theme-color: #88ff88;}' -dmenu) +if [[ -z "$ROFI" ]] ; then + ROFI='rofi -dmenu' +fi + +DMENU=($ROFI -i -theme-str '* {theme-color: #88ff88;}') sinks="$( pactl list sinks | while read line ; do diff --git a/extras/HOME/.local/bin/set-volume.sh b/extras/HOME/.local/bin/set-volume.sh new file mode 100755 index 0000000..94423d0 --- /dev/null +++ b/extras/HOME/.local/bin/set-volume.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +rofi=($ROFI -theme-str "* {theme-color: #88ffff;}") + +if [[ "$1" == "-a" ]] ; then + sinks="$(pactl list sinks | (while read line ; do + case $line in + Description:*) + descr=${line//*: } + ;; + Sink\ \#*) + if [ ! -z "$sink" ] ; then + echo "$state $descr ($volume)|$sink" + fi + sink=${line//*#} ;; + Volume:*) + volume=$(sed 's/.* \([0-9]\+%\).*/\1/g' <<< "$line") + ;; + *State:*) + state=${line//*: } + if [[ "$state" == 'RUNNING' ]] ; then + state='⏺' + else + state=' ' + fi ;; + esac + done + echo "$state $descr ($volume)|$sink"))" + sinks="$(grep "^⏺" <<< "$sinks" ; grep -v "^⏺" <<< "$sinks")" + + sink_inputs="$(pactl list sink-inputs | (while read line ; do + case $line in + *application.name\ =*) + app="${line//*= \"}" + app="${app%%\"}" + ;; + *media.name\ =*) + media="${line//*= \"}" + media="${media%%\"}" + ;; + *Volume:*) + volume=$(sed 's/.* \([0-9]\+%\).*/\1/g' <<< "$line") + ;; + Sink\ Input\ \#*) + if [ ! -z "$sink" ] ; then + echo "⏺ $app: $media ($volume)|$sink" + fi + sink=${line//*#} ;; + esac + done + echo "⏺ $app: $media ($volume)|$sink"))" + + selection=$( + (echo "$sinks" ; echo '' ; echo "$sink_inputs") | \ + cut -d'|' -f1 | \ + "${rofi[@]}" -p "Set Volume For") + + if [[ -z "$selection" ]] ; then + echo "Cancelled" >&2 + exit 0 + fi + + value=$(grep "$selection" <<< "$sinks") + command="set-sink-volume" + if [[ -z "$value" ]] ; then + command="set-sink-input-volume" + value=$(grep "$selection" <<< "$sink_inputs") + if [[ -z "$value" ]] ; then + echo "Invalid Selection" >&2 + exit 1 + fi + fi + echo "Setting $value" + value=${value//*|} +else + command="set-sink-volume" + value="@DEFAULT_SINK@" +fi + +volume=$(echo '10% + 20% + 30% + 40% + 50% + 60% + 70% + 80% + 90% + 100% + 110% + 120% + 130%' | "${rofi[@]}" -p 'Set Volume To') + +echo pactl "$command" "$value" "$volume" +pactl "$command" "$value" $volume diff --git a/src/Internal/DMenu.hs b/src/Internal/DMenu.hs index f964544..b611d87 100644 --- a/src/Internal/DMenu.hs +++ b/src/Internal/DMenu.hs @@ -16,9 +16,17 @@ data Colors = bg :: String } | DefaultColors +menuCommand :: [String] +menuCommand = ["rofi", "-monitor", "-4", "-dmenu"] + +menuCommandString :: String +menuCommandString = unwords menuCommand + runDMenu :: X () runDMenu = void $ - safeSpawn "rofi" ["-display-run", "Execute", "-show", "run"] + safeSpawn + "rofi" + ["-monitor", "-4", "-display-run", "Execute", "-show", "run"] runDMenuPrompt :: String -> Maybe String -> [String] -> X String runDMenuPrompt prompt color select = @@ -34,5 +42,5 @@ runDMenuPromptWithMap :: String -> Maybe String -> Map String a -> X (Maybe a) runDMenuPromptWithMap prompt color map = do let realColor = maybe [] ( \c -> ["-theme-str", printf "* {theme-color: %s;}" c]) color - menuMapArgs "rofi" - (["-p", prompt, "-dmenu"] ++ realColor) map + menuMapArgs (head menuCommand) + (tail menuCommand ++ ["-p", prompt] ++ realColor) map diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs index bf9b62c..51a1453 100644 --- a/src/Internal/Keys.hs +++ b/src/Internal/Keys.hs @@ -228,6 +228,9 @@ keymap = runKeys $ do str (show (map ord str)) + bind xK_n $ do + (justMod -|- noMod) $ spawn (terminal config ++ " -t Notes -e notes new") + bind xK_c $ do shiftMod CopyWindow.killAllOtherCopies @@ -237,6 +240,13 @@ keymap = runKeys $ do bind xK_a $ (justMod -|- noMod) $ spawn "set-sink.sh" + + bind xK_w $ + (justMod -|- noMod) $ spawn "networkmanager_dmenu" + + bind xK_v $ do + (justMod -|- noMod) $ spawn "set-volume.sh" + (shiftMod -|- rawMask shiftMask) $ spawn "set-volume.sh -a" -- Double-tap Z to toggle zoom. diff --git a/src/Main.hs b/src/Main.hs index da3b4f1..f70496c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -13,9 +13,10 @@ import Data.Monoid import Internal.XMobarLog import Internal.Keys import Internal.Layout +import Internal.DMenu (menuCommandString) import qualified XMonad as X -import qualified XMonad.StackSet as S +import qualified XMonad.StackSet as W main = do @@ -24,6 +25,7 @@ main = do let fp = homeDir </> ".xmonad" </> "startup" setEnv "SUDO_ASKPASS" "/usr/bin/ssh-askpass" + setEnv "ROFI" menuCommandString xmobar <- spawnXMobar @@ -43,7 +45,8 @@ main = do , className =? "yakuake" --> doFloat , className =? "MPlayer" --> doFloat , title =? "Event Tester" --> doFloat - , title =? "Floating Term" --> doFloat + , title =? "Floating Term" --> doCenterFloat + , title =? "Notes" --> doCenterFloat , title =? "xmessage" --> doFloat , title =? "gxmessage" --> doFloat , className =? "mpv" --> doFloat @@ -55,3 +58,10 @@ main = do , clickJustFocuses = False , logHook = xMobarLogHook xmobar } + +doCenterFloat :: ManageHook +doCenterFloat = + ask >>= \w -> doF . W.float w . centerRect . snd =<< liftX (floatLocation w) + +centerRect :: W.RationalRect -> W.RationalRect +centerRect (W.RationalRect x y w h) = W.RationalRect ((1 - w) / 2) ((1 - h) / 2) w h |