diff options
Diffstat (limited to '.local/bin/rws')
-rwxr-xr-x | .local/bin/rws | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/.local/bin/rws b/.local/bin/rws deleted file mode 100755 index 7041e8c..0000000 --- a/.local/bin/rws +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh - -# rebecca workspace -# -# source this from your shell rc file -# and also start rws -listen when you start sway - - -WSD=$XDG_RUNTIME_DIR/ws -mkdir -p $WSD - - - -wslist () { - # list workspaces, most-recently-used first - swaymsg -t get_workspaces | jq -rc '.[] | .name' | while read wsn; do - wsp=$WSD/"$(printf %s "$wsn" | base64)" - dt="$(stat -c '%Y' $wsp 2>/dev/null)" - if [ $? -eq 1 ]; then - dt=1 - fi - printf "%s\t%s\n" "$dt" "$wsn" - done | sort -nr | cut -f2- -} - -_escape() { - printf %s "$1" | sed -e 's*\\*\\\\*g' -e 's*"*\\"*g' -} - -workin () { - # cds to the given directory, then moves focused window to workspace - # with that name - if [ ! -d "$1" ]; then - printf "not a directory\n" >&2 - return 1 - else - cd "$1" - dirname="$(_escape "$(apwd)")" - swaymsg "move container to workspace \"$dirname\"" - swaymsg "workspace \"$dirname\"" - fi -} - - -curws () { - # prints name of current workspace - swaymsg -t get_workspaces \ - | jq -rc '.[] | select(.focused==true) | .name' -} -gowork() { - # cds to working directory for current workspace - d="$(curws|sed -e "s*^~*$HOME*")" - if [ -d "$d" ]; then - cd "$d" || return 1 - fi -} -renws () { - # renames current ws to current working dir - swaymsg "rename workspace to $(apwd)" -} - -queryws () { - # uses bmenu to prompt for a workspace name, then switches to that workspace - # or if -m given, moves focused window to that workspace instead - wsn="$(wslist | bemenu -p workspace -l100 --fn 'Iosevka Fixed 16' --tf '#df73ff' --hf '#df73ff' --hb '#333333')" - [ -z "$wsn" ] && return - - if [ "$1" = "-m" ]; then - swaymsg "move container to workspace \"$(_escape "$wsn")\"" - else - swaymsg "workspace \"$(_escape "$wsn")\"" - fi -} - - -_onswitch () { - wsb=$(printf %s "$1" | base64) - touch ${WSD}/$wsb -} -# run rws -listen to listen for workspace changes, -# and keep track of that -if [ "$1" = "-listen" ]; then - swaymsg -rmt subscribe '[ "workspace" ]' | while read line; do - wsn="$(printf %s "$line" | jq -rc '.current.name')" - printf "%s\n" "$wsn" - _onswitch "$wsn" - done -fi - -# rws -queryws does the same thing as queryws -# because it needs to be runnable from sway cfg in order to keybind something for it -if [ "$1" = "-queryws" ]; then - shift - queryws $@ -fi - - - - |