Skip to content

Instantly share code, notes, and snippets.

@danielsanfr
Created May 11, 2019 14:31
Show Gist options
  • Save danielsanfr/970aeb7232041544f17c15c5af510813 to your computer and use it in GitHub Desktop.
Save danielsanfr/970aeb7232041544f17c15c5af510813 to your computer and use it in GitHub Desktop.
Adjust WM_CLASS of Android Studio Beta version on GNU/Linux (and X.org) so you can have 2 different icons on docks
#!/bin/sh
# Update WM_CLASS
fault_tolerance=0
beta_timeout=50
while true; do
wids=$(timeout 2 xdotool search --sync --onlyvisible --class "jetbrains-studio")
if [ -z "$wids" ] ; then
if [ $fault_tolerance -eq 0 ]; then
fault_tolerance=1
else
echo "Can't find any Android Studio Beta window"
exit 0
fi
else
fault_tolerance=0
fi
for wid in $wids; do
pid=$(xdotool getwindowpid $wid)
if [ ! -z "$pid" ] ; then
path=$(readlink -f /proc/$pid/exe)
if [[ $path == *"beta"* ]]; then
echo "Find Android Studio Beta window!"
beta_timeout=50
xprop -id $wid -f WM_CLASS 8s -set WM_CLASS "jetbrains-studio-beta"
else
beta_timeout="$(($beta_timeout-1))"
if [ $beta_timeout -eq 0 ]; then
echo "Can't find any Android Studio Beta window"
exit 0
fi
fi
fi
done
done
@mukou
Copy link

mukou commented May 6, 2024

Thank you very much, this method helped me

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