clientmenu - bakkeby/dusk GitHub Wiki
clientmenu
is an example test script that can be used to inspect client flags during runtime.
It is entirely optional and is not included in the default configuration. The script uses xmenu for presentation purposes.
Here is a demonstration holding down Super+Alt
and right-clicking on a client window:
The script can either be set up externally via sxhkd or via configuration within the window manager.
super + alt + button3
/path/to/clientmenu
The advantage of configuring it for sxhkd is that it is very easy to do.
The path to the script must be defined in config.h:
static const char *clientmenu[] = { NULL, "/path/to/clientmenu", NULL };
A spawn keybinding needs to be added.
static Button buttons[] = {
/* click event mask button function argument */
...
{ ClkClientWin, MODKEY|Alt, Button3, spawn, {.v = clientmenu } },
...
The advantage of configuring it within the window manager is that the script will only run when the mouse cursor is pointing at a specific window.
This will likely need to be moved somewhere else at some point, but for now the script is provided as-is within this wiki.
The clientmenu
shell script:
#!/bin/sh
if [ -z $IPCCMD ]; then
IPCCMD=duskc
fi
bind_clientmenu() {
WINID=$($IPCCMD get_monitors | jq '.[] | select(.is_selected == true) | .clients.selected')
JSON=$($IPCCMD get_client $WINID)
NAME=$(echo $JSON | jq '.name' | sed 's/"//g')
echo $JSON | jq '.flags' | awk -F":" -vNAME="$NAME" '
BEGIN {
print "#INDENT#" NAME
print "#INDENT#\tKill Client\t#IPCCMD# run_command killclient"
print "#INDENT#\tToggle Floating\t#IPCCMD# run_command togglefloating"
print "#INDENT#"
}
NF == 1 {
next
}
{
gsub(/^ |"|,/, "");
print "#INDENT#" $1 ": " $2 "\t#IPCCMD# run_command toggleclientflag " $1
}
' | sed -e "s/#INDENT#/$1/" -e "s/#IPCCMD#/${IPCCMD}/"
}
# Allow the above menu to be sourced by other scripts by setting
# the SOURCE_MENU environment variable.
if [ -z $SOURCE_MENU ]; then
$(bind_clientmenu | xmenu)
fi
The gist of it is that it uses the dusk client to find the window ID of the selected client on the selected monitor.
Then further details for the client are pulled out and a menu is formatted based on the flags returned.
Back to Functions > toggleclientflag.