Optional argument "-m | hide GUI on startup" doesn't work

Open
#4,175 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
desktop

Research direction

Start by reproducing the issue with electrum gui -m, then inspect main_window.py around load_wallet() and bring_to_top(), and __init__.py around start_new_window(). The change is done when -m leaves the wallet window hidden for both encrypted and unencrypted wallets, while selecting Show from the tray still permits the password prompt and window to appear.

Written by the indexing model from the issue text.

Description

bug 🐞 user-interface 🔲

Running electrum 3.1 compiled from git today on Arch Linux with GNOME Shell 3.26.2.

Objective: set up electrum to autostart on login without opening any window, just the tray icon.

$ electrum help gui
[...]
optional arguments:
  -m                    hide GUI on startup

However, it doesn't work. I tried removing the wallet encryption, because I thought it was the password prompt that skewed the hiding of the GUI, but without wallet encryption it just straight opens the wallet anyways.

Step to reproduce the error (assuming everything is already configured):

$ electrum gui -m

Research:

The problem apparently relies on bring_to_top() [main_window.py:276] function being called - probably from __init__ - after this code in load_wallet() [main_window:338] that's supposed to make the -m flag work:

if self.config.get('hide_gui') and self.gui_object.tray.isVisible():
    self.hide()
else:
    self.show()

Commenting out w.bring_to_top() [__init__.py:236] in start_new_window)() [__init__.py:187] makes it work as intended:

def start_new_window(self, path, uri):
    '''Raises the window for the wallet if it is open.  Otherwise
    opens the wallet and creates a new window for it'''
    [...]
    if uri:
        w.pay_to_URI(uri)
    #w.bring_to_top()
    w.setWindowState(w.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
    [...]
    return w

But, of course, just generates more problems. That probably means we need another check for self.config.get('hide_gui') in __init__.py, I did it like this:

if not self.config.get('hide_gui'):
    w.bring_to_top()

That solved the problem for me, but only for unencrypted wallets. If the wallet is encrypted electrum still pops up for the password, which would be nice if it only did when you selected "Show" on the tray icon menu.

Dominant language
Python
Stars
8.6k
Forks
3.5k
Avg merge
2d 8h
Merged PRs (30d)
61

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spesmilo/electrum

All issues in spesmilo/electrum

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.