How do I get the Qube color/label of current active window in bash?
Hi @ian,
For the label it’s very simple : xdotool getwindowfocus getwindowname
For the color, take what you want from this too complex one-line command : qvm-ls --fields=NAME,LABEL| grep ^$(xprop -id $(xdotool getwindowfocus) | grep ^WM_CLIENT_MACHINE | cut -d\" -f2 )
And don’t forget, man is your friend.
Note: I renamed the topic
Or the more generic,
#!/bin/bash
ID=`xdotool getwindowfocus`
QUBE=`xprop _QUBES_VMNAME -id $ID|cut -f2 -d\" `
if [[ "$QUBE" == "_QUBES_VMNAME: not found." ]]; then
exit
else
# Do something with $QUBE
fi
qvm-prefs $QUBE label will give the color.
If I run the script while dom0 is not focused (by putting sleep 8 && in front of the command) it outputs the name and label of every qube.
not for me:
[user@dom0 ~]$ sleep 8 && xdotool getwindowfocus getwindowname
Before the end of the 8 seconds if I focus a new window, then I get the new focused window name.
Experiment with the simple label name (xdotool getwindowfocus getwindowname) when you get it, then understand the color part. Do it step by step.
The objective isn’t to give you a solution but it’s you understand the command and tune it to your needs.
Note: for the color, tune the unman’s script which is much better.