Skip to content

Instantly share code, notes, and snippets.

@wwalker
Created September 21, 2021 01:24
Show Gist options
  • Save wwalker/97fc461679dcc26331c0f9dcf693b22d to your computer and use it in GitHub Desktop.
Save wwalker/97fc461679dcc26331c0f9dcf693b22d to your computer and use it in GitHub Desktop.
i3 + rofi + setting window roles
bindsym --release Shift+$super+m exec --no-startup-id set-wm-window-role
# My rofi setup for window mode. ONLY matches on role
bindsym $super+l exec --no-startup-id "rofi -show window -window-match-fields role -sort -auto-select -sorting-method fzf -show-icons -matching regex -filter ^"
#!/bin/bash -ex
_basename=$( basename "$0" )
_error() { printf 'ERROR: %s\n' "${1?}" >&2; }
_info() { printf 'INFO: %s\n' "${1?}"; }
usage(){
printf "%s\n" "$_basename"
printf "Sets WM_WINDOW_ROLE on the selected window using i3-input to get the name\n"
exit 1
}
log(){
# shellcheck disable=SC2059
printf "$@" 1>&2
}
die(){
exit_code=1
if [[ $1 =~ ^[0-9][0-9]*$ ]]
then
exit_code=$1
shift
fi
printf "%s\n" "$@"
printf "Exiting.\n"
exit "$exit_code"
}
# id=$( xwininfo | grep Window\ id: | awk '{print $4}' )
id=$( i3-msg -t get_tree | jq '.. | select(.focused? == true).window' )
name=$1
if [[ -z "$name" ]]; then
name=$( rofi -dmenu -P 'Enter new WM_WINDOW_ROLE property value: ' -l 0 )
[[ -z "$name" ]] && die "Empty input"
fi
xprop -id "$id" -f WM_WINDOW_ROLE 8s -set WM_WINDOW_ROLE "$name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment