Skip to content

Instantly share code, notes, and snippets.

@kelvinauta
Last active June 7, 2025 09:56
Show Gist options
  • Save kelvinauta/d9ec6a5798a2645fa5621d7f98a80883 to your computer and use it in GitHub Desktop.
Save kelvinauta/d9ec6a5798a2645fa5621d7f98a80883 to your computer and use it in GitHub Desktop.
Print useful information about the window node by retrieving data from bspwm and X11 Also displays it via notify-send
#!/usr/bin/env bash
# Print useful information about the window node by retrieving data from bspwm, X11 and Process Info (PID, RAM, CPU)
# Also displays it via notify-send
# Recommended usage: Add a keybinding in sxhkdrc to execute this script and run it only on the currently focused window to receive a notification with useful node information
# Requirements: bspwm (bspc), jq, xprop (x11-utils), notify-send (libnotify), servidor X11
set -e
node_id=${1:-$(bspc query -N -n focused)}
if [[ -z "$node_id" ]]; then
echo "WARN: No focused node"
exit 1
fi
node_json=$(bspc query -T -n "$node_id")
class=$(echo "$node_json" | jq -r '.client.className // empty')
name=$(echo "$node_json" | jq -r '.client.name // empty')
state=$(echo "$node_json" | jq -r '.client.state // empty')
layer=$(echo "$node_json" | jq -r '.client.layer // empty')
pid=$(echo "$node_json" | jq -r '.client.pid // empty')
wm_class=$(xprop -id "$node_id" WM_CLASS 2>/dev/null | cut -d '"' -f2)
wm_name=$(xprop -id "$node_id" WM_NAME 2>/dev/null | cut -d '"' -f2)
flags_arr=()
for key in hidden sticky private locked marked urgent; do
if [[ "$(echo "$node_json" | jq -r ".${key} // false")" == "true" ]]; then
flags_arr+=("$key")
fi
done
flags=$(IFS=,; echo "${flags_arr[*]}")
msg=""
[ -n "$class" ] && msg+=" Class: $class\n"
[ -n "$name" ] && msg+=" Name: $name\n"
[ -n "$node_id" ] && msg+=" Node ID: $node_id\n"
[ -n "$state" ] && msg+=" State: $state\n"
[ -n "$flags" ] && msg+=" Flags: $flags\n"
[ -n "$wm_class" ] && msg+="󰊗 X11 Class: $wm_class\n"
[ -n "$layer" ] && msg+=" Layer: $layer\n"
[ -n "$pid" ] && msg+=" PID: $pid\n"
[ -n "$wm_name" ] && msg+=" Title: $wm_name\n"
if notify-send "Node Info" "$msg"; then
echo -e "$msg"
else
echo "WARN: Notification failed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment