Skip to content

Commit

Permalink
add new function xname
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Jun 21, 2015
1 parent 90ffa05 commit c48062c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,27 @@ gogo(){
# enter the first path found
cd "${path[0]}"
}

# get the name of a x window
xname(){
local window_id=$1

if [[ -z $window_id ]]; then
echo "Please specifiy a window id, you find this with 'xwininfo'"

return 1
fi

local match_string='".*"'
local match_int='[0-9][0-9]*'
local match_qstring='"[^"\\]*(\\.[^"\\]*)*"' # NOTE: Adds 1 backreference

# get the name
xprop -id $window_id | \
sed -nr \
-e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \
-e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \
-e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \
-e "/^_NET_WM_NAME\(UTF8_STRING\) = ($match_qstring)$/{s//title=\1/; h}" \
-e '${g; p}'
}
1 change: 1 addition & 0 deletions .i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ for_window [class="NES"] floating enable
for_window [class="Portal"] floating enable
for_window [class="Skype"] floating enable
for_window [class="Steam"] floating enable
for_window [class="Tor Browser"] floating enable
for_window [class="VirtualBox"] floating enable
for_window [class="vlc"] floating enable
for_window [class="Wine"] floating enable
Expand Down

0 comments on commit c48062c

Please sign in to comment.