Skip to content

Instantly share code, notes, and snippets.

@BrodieRobertson
Forked from jpentland/tabc.sh
Last active June 13, 2025 21:50
Show Gist options
  • Save BrodieRobertson/dd7e3d793a501066c50086ed795c0357 to your computer and use it in GitHub Desktop.
Save BrodieRobertson/dd7e3d793a501066c50086ed795c0357 to your computer and use it in GitHub Desktop.
Add or remove windows from suckless' tabbed
#!/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
@erikLundstedt
Copy link

I was just looking for (almost)this, clicked the top ddg result, HUGE fan of your stuff
too bad it require the use of bspwm as I never really used that one, I'm still on awesome and loving it to the point of being unable to move to Wayland (there are other reasons too, like no x over ssh stuff which is something I actually find quite useful at times)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment