Created
August 10, 2018 18:10
-
-
Save jvalrog/f5ecb330c21959908d40fe214cfb4311 to your computer and use it in GitHub Desktop.
Bash script that assigns windows to certain workspaces
This file contains 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/bash | |
################################################################################# | |
# | |
# "xorganizer" is a simple bash script that assigns windows to certain workspaces | |
# by using the xdotool command. | |
# | |
# Supports matching by "class", "classname" and "name". | |
# It can be restarted on the spot by sending the SIGHUP signal. | |
# | |
# Rule format: | |
# <match_type> <match_string> <workspace_number> | |
# | |
# Example: | |
# rules() { | |
# class gimp 3 | |
# classname ^xterm$ 2 | |
# name "irssi chat" 4 | |
# } | |
# | |
rules() { | |
dummy_rule # remove this rule and add your own. | |
} | |
# | |
################################################################################# | |
add_rule_by() { RULES+=("search --$1 \"$2\" set_desktop_for_window %@ $(($3 - 1))"); } | |
class() { add_rule_by class "$@"; } | |
classname() { add_rule_by classname "$@"; } | |
name() { add_rule_by name "$@"; } | |
dummy_rule() { :; } | |
trap 'exec $(readlink -f "$0")' SIGHUP | |
rules | |
while true; do | |
printf "%s\n" "${RULES[@]}" | xdotool - | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment