backintime icon indicating copy to clipboard operation
backintime copied to clipboard

Permanent system tray icon (not only when taking a snapshot)

Open aryoda opened this issue 3 years ago • 5 comments

@Anard requested this feature in another unrelated issue so I have added it as new feature request

I would like to have access to BackInTime in systray even if it's not taking a snapshot as eg. done by TimeMachine on macOS, allowing to launch BiT or take a snapshot instantly without launching the app.

aryoda avatar Nov 22 '22 02:11 aryoda

I think a permanent systray icon could be shown for the user (and one extra possibly for BiT root) by

  • removing the code that exists when the BiT job is no longer busy: https://github.com/bit-team/backintime/blob/1003d360d758bce78c6cd528ea41df3734fec95b/qt/qtsystrayicon.py#L146-L150
  • adding a menu item to close the systray icon
  • showing the user name in the systray icon tooltip or menu
  • adding logic to prevent starting multiple instances, e.g. by reusing applicationinstance.py to maintain an extra PID file: https://github.com/bit-team/backintime/blob/1003d360d758bce78c6cd528ea41df3734fec95b/common/applicationinstance.py#L57-L67
  • finding a way to autostart the systray icon on every distro (this looks like packaging/package maintainer task since it depends on the distro and Linux version

aryoda avatar Jul 16 '23 19:07 aryoda

I could add an additional experimental argument to qtsystrayicon.py quite easily (+ a starter script for testing it)...

aryoda avatar Jul 16 '23 19:07 aryoda

In the past I investigated different approaches how to upgrade our upstream repo to the current python packaging standards (using src-layout; pyproject.toml without setup.cfg and setup.py; without sys.path hacking; install via Developlment Mode using pip's --editable install; ...). I also discussed this with debian maintainers to take there needs into account.

I'm not finished yet. But I'm quit sure that the best solution is to treat "backintime" (the CLI) and "backintim-qt" (the GUI) as separate packages. It is not very different from what we do currently.

So I ask myself if it might be a good idea to treat the systray component as a separate package, too? But we also could treat it as part of "backintime-qt". In that case we would just defined an additional entry point (resulting in a /usr/bin starter script like "backintime" and "backintime-qt") in that python package to start the systray.

buhtz avatar Jul 17 '23 07:07 buhtz

So I ask myself if it might be a good idea to treat the systray component as a separate package, too?

Very good point. The code should stay in backintime-qt since it mostly reuses existing code. A starter script should also be in backintime-qt.

To enable a permanent systray icon a new package could be used to execute the starter script when the user logs in. This package would depend only on backintime-qt. We could even introduce multiple packages if "autostarting" the systray icon requires different settings on different distros (but then we would take on the pkg maintainer role again - do we want this at all?).

aryoda avatar Jul 17 '23 07:07 aryoda

It is quit easy to have multiple starter scripts for one package. As an example of my demo here a snipped from the pyproject.toml:

[tool.setuptools.package-dir]
bitcli = "src/bitcli"
bitgui = "src/bitgui"

[project.scripts]
bitcli = "bitcli.__main__:main"
bitcli-root = "bitcli.__main__:run_main_as_root_via_policykit"
bitgui = "bitgui.__main__:main"
bitgui-root = "bitgui.__main__:run_main_as_root_via_policykit"

This is not the final solution with two separate packages I have in mind! It is just one distribution package (name d bitdemo) offering two import packages (bitcli & bitgui).

Because of the first section [tool.setuptools.package-dir] you can do import bitcli and import bitgui.

More interesting is the section [project.scripts] offering four entry points. Pip/setuptools (which will be used by debian maintainers, too) do generate four starter scripts in /usr/bin.

I used that demo repo to illustrate our needs in the discussion with Debian maintainers and with the folks from pip and setuptools. I will add the systray aspect to the demo, too. I just stoped with that demo because I realized that it is damn to early migrating BIT to the new packaging standards. There are much more emerging issues. 😃

buhtz avatar Jul 17 '23 08:07 buhtz