Skip to content

Instantly share code, notes, and snippets.

@jvalrog
Created August 10, 2018 18:10
Show Gist options
  • Save jvalrog/f5ecb330c21959908d40fe214cfb4311 to your computer and use it in GitHub Desktop.
Save jvalrog/f5ecb330c21959908d40fe214cfb4311 to your computer and use it in GitHub Desktop.
Bash script that assigns windows to certain workspaces
#!/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