-
-
Save thomasgroch/b089e9e7133a778685cd181be183c241 to your computer and use it in GitHub Desktop.
Launch Signal if not running, otherwise toggle hidden/shown state. Put signal.desktop in ~/.config/autostart/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
run () { | |
signal-desktop & | |
disown | |
} | |
show () { | |
local -r id="$1" | |
idx="$(printf "0x%08x" "${id}")" | |
wmctrl -i -r "${idx}" -b remove,skip_taskbar,skip_pager | |
wmctrl -i -R "${idx}" # really make sure it's raised | |
xdotool windowraise "${id}" | |
} | |
hide () { | |
local -r id="$1" | |
idx="$(printf "0x%08x" "${id}")" | |
wmctrl -i -r "${idx}" -b add,skip_taskbar,skip_pager | |
xdotool windowminimize "${id}" | |
} | |
get_id () { | |
xdotool search --name '^Signal( \([0-9]+\))?$' | |
} | |
missing=false | |
if ! command -V wmctrl >/dev/null; then | |
echo "Please install wmctrl" | |
missing=true | |
fi | |
if ! command -V xdotool >/dev/null; then | |
echo "Please install xdotool" | |
missing=true | |
fi | |
if ! command -V xprop >/dev/null; then | |
echo "Please install x11-utils" | |
missing=true | |
fi | |
if "${missing}"; then exit 1; fi | |
if ! id="$(get_id)"; then | |
run | |
if [[ $1 = hide ]]; then | |
for i in {1..20}; do | |
if id="$(get_id)"; then hide "${id}"; break; fi | |
sleep 0.5 | |
done | |
fi | |
else | |
if xprop -id "${id}" | grep -q '^_NET_WM_STATE(ATOM) =.* _NET_WM_STATE_SKIP_PAGER'; then | |
show "${id}" | |
else | |
hide "${id}" | |
fi | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Encoding=UTF-8 | |
Version=0.1.2 | |
Type=Application | |
Name=Start Signal minimized or toggle | |
Comment=Start Signal Private Messenger and immediately hide it, or toggle if already running | |
Exec=/path/to/above/signal hide | |
StartupNotify=false | |
Terminal=false | |
Hidden=false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment