diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-09-24 22:15:16 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-09-24 22:15:16 +0300 |
commit | 0e618f52f5036a91060c564a8d4fb0f6d51ce6de (patch) | |
tree | df75ba7e71da28571e56769a3bad8411dce2009b | |
parent | 954b6ca08eac7c3da5db8c3370c107074c5010f5 (diff) | |
download | swayrice-0e618f52f5036a91060c564a8d4fb0f6d51ce6de.tar.gz swayrice-0e618f52f5036a91060c564a8d4fb0f6d51ce6de.zip |
Improved "dropdown" terminal script
also removed unused ddtelegram
-rw-r--r-- | dotfiles/.config/sway/config | 5 | ||||
-rwxr-xr-x | dotfiles/.local/bin/ddquakemite | 42 | ||||
-rwxr-xr-x | dotfiles/.local/bin/ddtelegram | 12 |
3 files changed, 36 insertions, 23 deletions
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config index b9f98bd..93082c3 100644 --- a/dotfiles/.config/sway/config +++ b/dotfiles/.config/sway/config @@ -212,10 +212,11 @@ bindsym --to-code { # Dropdown/scratchpad applications $mod+Shift+p exec ddquakemite + $mod+Ctrl+p exec ddquakemite -r # Switch/swap windows - $mod+bracketright exec "menuwin" - $mod+Shift+bracketright exec "menuwin -s" + $mod+bracketright exec menuwin + $mod+Shift+bracketright exec menuwin -s # Sticky float to a bottom corner $mod+Shift+b floating toggle; sticky toggle; exec picinpic diff --git a/dotfiles/.local/bin/ddquakemite b/dotfiles/.local/bin/ddquakemite index 0393f1e..4d304bc 100755 --- a/dotfiles/.local/bin/ddquakemite +++ b/dotfiles/.local/bin/ddquakemite @@ -1,17 +1,41 @@ #!/bin/sh -if ! [ -z "$(swaymsg -t get_tree | grep 'ddterminal')" ]; then - if [ -z "$(swaymsg -t get_tree | grep -A 46 'ddterminal' | tail -n 1 | grep 'true')" ]; then - swaymsg '[title="ddterminal"] scratchpad show' - else - swaymsg '[title="ddterminal"] move scratchpad' - fi -else - $TERMINAL -T "ddterminal" tmuxatt & - sleep 0.2s +# Yaroslav de la Peña Smirnov 2019-2022 +# hacky script to spawn a dropdown-like terminal for quickly typing some +# commands + +# reposition the terminal right below the status bar; as a side effect, this +# can be used with any floating window, not just ddterminal by calling the +# script with '-r' +reposition() { curwiny=$(swaygetcurrentwindow | cut -d ' ' -f1 | cut -d ',' -f2 ) curdisy=$(swaymsg -pt get_outputs | grep -A3 focused | grep Position | cut -d ',' -f2) moveup=$(($curwiny - $curdisy - 30)) swaymsg move up "$moveup px" +} + +if [ "$1" = "-r" ]; then + reposition + exit +fi + +ddstatus=$(swaymsg -t get_tree | jq -r ' + .. + | objects + | select(.type == "workspace") as $ws + | .. + | objects + | select(has("app_id")) + | select(.name == "ddterminal") + | (if .focused == true then "+" else "-" end)') + +if [ "$ddstatus" = "-" ]; then + swaymsg '[title="ddterminal"] scratchpad show' +elif [ "$ddstatus" = "+" ]; then + swaymsg '[title="ddterminal"] move scratchpad' +else + $TERMINAL -T "ddterminal" tmuxatt & + sleep 0.2s + reposition fi diff --git a/dotfiles/.local/bin/ddtelegram b/dotfiles/.local/bin/ddtelegram deleted file mode 100755 index 8ddff22..0000000 --- a/dotfiles/.local/bin/ddtelegram +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if pidof telegram-desktop > /dev/null; then - if [ -z $(swaymsg -t get_tree | grep -A 1 'telegramdesktop' | tail -n 1 | grep 'true') ]; then - swaymsg '[app_id="telegramdesktop"] scratchpad show' - else - swaymsg '[app_id="telegramdesktop"] move scratchpad' - fi -else - telegram-desktop -fi - |