简体   繁体   中英

How can I start Thunderbird and minimize the window on startup in Ubuntu

I'm trying to have Thunderbird open on startup and have its window hidden or minimized. I have been able to accomplish this with some other applications, but Thunderbird doesn't seem to have any handy options for opening into the tray or minimized.

I've written a bash script and included it in the Startup gui. This script is largely based off of what I read here: Bash wait for process start . And here is my script:

#! /bin/bash

thunderbird &
while pids=$(pidof thunderbird)
do
    sleep 1s
done
sleep 3s
xdotool search --onlyvisible --class thunderbird windowminimize

I also tried without the "&" in thunderbird & and I tried without the while loop and instead having a very long sleep wait. If I run a script with the following lines within the terminal (not at startup), it works just fine:

thunderbird &
sleep 3s
xdotool search --onlyvisible --class thunderbird windowminimize

Am I doing something wrong with the loop? Or is there something with the startup process that makes this not work? I also have other applications starting up, but I don't think those would interfere with this. I'm pretty new to Linux.

I'm just copy pasting this ask ubuntu answer :

I achieved the desired behaviour in the following way:

1) Install alltray which provides an easy method to open Thunderbird at startup:

sudo apt update
sudo apt install alltray

2) Add to Startup Applications:

启动应用程序

This will open Thunderbird at startup but it will not be minimised.

----- UPDATE Minimize on Start and Close IS NO LONGER SUPPORTED -----

3) Then install Minimize on Start and Close in Thunderbird (Tools->Add-ons->Get Add-ons)

This needs to be configured (Tools->Add-ons->Extensions->Preferences) as follows:

附加配置

--------------------------------------------------

3) Then install Keep in Taskbar and restart Thunderbird.

This is a combination of previous suggestions from various locations that works in Ubuntu 16.04.

I thought I would share this to provide an easy, updated method for others.

I found the answer here . I just copied and pasted the answer's second python script.

Install xdotool sudo apt install xdotool

Create a file, I like it to be in PATH, eg sudo nano /usr/local/bin/startup-thunderbird with (Ctrl-Shift-V to paste in terminal):

#!/bin/bash
thunderbird &
while true; do
    sleep 1
    w=$(xdotool search --onlyvisible --name "Mozilla Thunderbird")
    if [ ! -z $w ]; then
        echo "minimizing $w"
        xdotool windowminimize $w
        break
    fi
done

Save it then make it executable sudo chmod +x /usr/local/bin/startup-thunderbird

Add startup-thunderbird to the commands in Startup Applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM