New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running from source using a .desktop file #176

Open
dufferzafar opened this Issue Mar 18, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@dufferzafar

dufferzafar commented Mar 18, 2018

I'm running activitywatch directly from source (latest master) and it is working fine:

$ cd ~/.apps/activitywatch
$ . venv/bin/activate
$ aw-qt

But I obviously don't want to manually do these steps every time I start my machine. So I created a .desktop file:

[Desktop Entry]
Name=ActivityWatch
Exec="/home/dufferzafar/.apps/activitywatch/venv/bin/aw-qt"
Icon=/home/dufferzafar/.apps/activitywatch/aw-qt/media/logo/logo.png
GenericName=Log what you do on your computer.
Type=Application
Terminal=false
Hidden=False
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-UniqueApplet=true
Categories=Utility;
X-GNOME-Autostart-enabled=true

But this .desktop file doesn't work, I get the following error when trying to launch it:

$ kioclient exec ~/.local/share/applications/activity-watch.desktop

kioclient(13640) ClientApp::kde_open: KUrl("file:///home/dufferzafar/.local/share/applications/activity-watch.desktop")
2018-03-18 11:00:27 [INFO ]: Starting module aw-server  (aw_qt.manager:46)
Traceback (most recent call last):
  File "/home/dufferzafar/.apps/activitywatch/venv/bin/aw-qt", line 11, in <module>
    sys.exit(main())
  File "/home/dufferzafar/.apps/activitywatch/venv/lib/python3.5/site-packages/aw_qt/main.py", line 19, in main
    _manager.autostart(args.autostart_modules)
  File "/home/dufferzafar/.apps/activitywatch/venv/lib/python3.5/site-packages/aw_qt/manager.py", line 137, in autostart
    self.start("aw-server")
  File "/home/dufferzafar/.apps/activitywatch/venv/lib/python3.5/site-packages/aw_qt/manager.py", line 130, in start
    self.modules[module_name].start()
  File "/home/dufferzafar/.apps/activitywatch/venv/lib/python3.5/site-packages/aw_qt/manager.py", line 59, in start
    self._process = subprocess.Popen(exec_cmd, universal_newlines=True)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'aw-server'

This is happening because it can't find aw-server in my $PATH. How can I change the $PATH attribute just for the .desktop file? or maybe there's some other way to get aw-qt to autostart?

@dufferzafar

This comment has been minimized.

dufferzafar commented Mar 18, 2018

After writing out the problem clearly, I realized what I had to do. Quick googling revealed the solution.

This is the final desktop file that worked for me (notice the setting of $PATH):

[Desktop Entry]
Name=ActivityWatch
Exec=sh -c "PATH=$HOME/.apps/activitywatch/venv/bin:$PATH $HOME/.apps/activitywatch/venv/bin/aw-qt"
Icon=/home/dufferzafar/.apps/activitywatch/aw-qt/media/logo/logo.png
GenericName=Log what you do on your computer.
Type=Application
Terminal=false
Hidden=False
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-UniqueApplet=true
Categories=Utility;
X-GNOME-Autostart-enabled=true

@ErikBjare ErikBjare referenced this issue Mar 18, 2018

Open

Document how to autostart for all platforms #116

1 of 4 tasks complete
@dufferzafar

This comment has been minimized.

dufferzafar commented Mar 22, 2018

@ErikBjare Do you think we should add a line for this in the running from source doc? https://github.com/ActivityWatch/docs/blob/master/installing-from-source.rst

Something like:

On linux, if you want to run from source using a .desktop file launcher. [See this issue.](https://github.com/ActivityWatch/activitywatch/issues/176)
@ErikBjare

This comment has been minimized.

Member

ErikBjare commented Mar 22, 2018

@dufferzafar Good idea, submit a PR and I'll merge 👍

@johan-bjareholt

This comment has been minimized.

Member

johan-bjareholt commented Mar 22, 2018

We could also ship the AUR package with a .desktop file since we can in that case guarantee the path of the executable.

@ErikBjare

This comment has been minimized.

Member

ErikBjare commented Mar 27, 2018

The .desktop file should also be added to /etc/xdg/autostart/ for the AUR package. This would automatically handle autostart for several desktop environments, as well as those who use dex -a in their custom setups (such as is the case for me who uses i3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment