-
-
Save BrodieRobertson/dd7e3d793a501066c50086ed795c0357 to your computer and use it in GitHub Desktop.
Add or remove windows from suckless' tabbed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# tabc.sh <command> | |
# Commands: | |
# add <direction-of-tabbed> <window-id> - Add window to tabbed | |
# remove <window-id> - Remove window from tabbed | |
# list <tabbed-id> - List all clients of tabbed | |
# | |
# Functions | |
# | |
# Get wid of root window | |
function get_root_wid { | |
xwininfo -root | awk '/Window id:/{print $4}' | |
} | |
# Get children of tabbed | |
function get_clients { | |
id=$1 | |
xwininfo -id $id -children | sed -n '/[0-9]\+ \(child\|children\):/,$s/ \+\(0x[0-9a-z]\+\).*/\1/p' | |
} | |
# Get class of a wid | |
function get_class { | |
id=$1 | |
if [ -z $id ]; then | |
echo "" | |
else | |
xprop -id $id | sed -n '/WM_CLASS/s/.*, "\(.*\)"/\1/p' | |
fi | |
} | |
# | |
# Main Program | |
# | |
cmd=$1 | |
if [ $cmd = "add" ]; then | |
tabbedid=$(bspc query -N -n $2) | |
if [ -z $tabbedid ]; then | |
tabbed & | |
sleep 0.1 | |
tabbedid=$(xdotool search --class tabbed | tail -n1) | |
fi | |
fi | |
case $cmd in | |
add) | |
wid=$3 | |
xdotool windowreparent $wid $tabbed | |
;; | |
remove) | |
wid=$2 | |
tabbedid=$(bspc query -N -n focused) | |
xdotool windowreparent $wid $(get_root_wid) | |
;; | |
list) | |
tabbedid=$2 | |
get_clients $tabbed | |
;; | |
esac |
@BrodieRobertson i would love to have the scirpt working again! Can you please help?
very annoying error! i think it has someting to do with being posix compliant.
.config/bspwm/tabc.sh: 15: function: not found 0x6bf .config/bspwm/tabc.sh: 17: Syntax error: "}" unexpected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a solution to retrieve the window id without using
sleep
. Hope it helps: plmi/dotfiles@71d1fd5#diff-126a1e1993e27b2e10ae75f52c689bcacc01f9dc135d345f4f910975126e43d1