Created
January 28, 2020 16:52
-
-
Save bokov/02d3b94cefcf81682ec5795220fa5f15 to your computer and use it in GitHub Desktop.
For gnome (maybe other window managers?) to launch apps minimized (using Teams as an example in the comments)
This file contains 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 | |
# usage: launchmin.sh /usr/bin/teams "Chat | Microsoft Teams" | |
# | |
# $1 is the path to an executable that runs in a window | |
# $2 is a quoted string to uniquely identify that window | |
# | |
# prerequisites: the xdotool and wmctrl packages need to be installed | |
# | |
# I wrote this to launch Microsoft Teams for Linux on startup but in a minimized | |
# window but it should work for any app if you can figure out a reliable pattern | |
# for matching its window title. Astonishingly, there is nothing built into the | |
# gnome tweaks or into the .desktop file specification that allows you to set | |
# minimize-on-start generically-- each app is responsible for providing its own | |
# command-line flags for doing so, if the author so chooses. So this will hack | |
# around this with xdotool and wmctrl. | |
# | |
# Note for Microsoft Teams, documented here in case needed later for other apps: | |
# If you add Exec=launchmin.sh /usr/bin/teams "Chat | Microsoft Teams" | |
# to a teams.desktop file, e.g. the one in $HOME/.config/autostart, the teams app | |
# will overwrite it with a vanilla version of its desktop file. To prevent that, | |
# make your changes to a copy of that file in the same directory. In the original | |
# teams.desktop file set X-GNOME-Autostart-enabled=false and make the file | |
# write-only. Now you will only have one instance of teams launching on startup, | |
# minimized. The other one will be ignored and Teams will not be able to | |
# overwrite it. | |
# | |
# Again, this script is not just for Microsoft Teams, the above is just a helpful | |
# note for those who happen to be using that app. | |
$1 && unset mywinid && while [ -z $mywinid ];do mywinid=$( wmctrl -l|grep "$2"|cut -d' ' -f1 ); sleep 1; done && xdotool windowminimize $mywinid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment