Skip to content

Instantly share code, notes, and snippets.

@bulatenkom
Last active March 14, 2024 13:56
Show Gist options
  • Save bulatenkom/c2946537f11c817e5add9002cc231594 to your computer and use it in GitHub Desktop.
Save bulatenkom/c2946537f11c817e5add9002cc231594 to your computer and use it in GitHub Desktop.
[Xorg, KDE, custom shortcuts] Script to focus/hide separate chrome window with opened ChatGPT
#!/usr/bin/env sh
get_active_desktop_num() {
wmctrl -d | awk '/*/{print NR-1}'
}
if wmctrl -l | grep -Eq "$(get_active_desktop_num) $(hostname) ChatGPTxyz"; then
# Hide (move window to unused virtual desktop)
wmctrl -r ChatGPTxyz -t 5
else
# Focus (move window to active virtual desktop and bring focus)
wmctrl -r ChatGPTxyz -t "$(get_active_desktop_num)"
wmctrl -a ChatGPTxyz
fi
@bulatenkom
Copy link
Author

bulatenkom commented Mar 13, 2024

Lock chrome window to ChatGPTxyz name: Chrome ⟶ (3 dots) ⟶ More tools ⟶ Name window...

Posted solution: Xorg only.

Following third party tools may help achieve the same behavior:
https://github.com/ReimuNotMoe/ydotool (xorg, wayland)
https://github.com/atx/wtype (wayland)

@bulatenkom
Copy link
Author

bulatenkom commented Mar 14, 2024

I bind this script to '+' button on numpad, since all buttons on numpad except numbers are unused.
KDE Custom Shortcuts executes script much faster, than simple Shortcuts (few seconds delay).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment