Closed Aditeya closed 1 year ago
Alright so I pushed a new version which implements something similar using a local unix socket. It is still a bit janky but it should work for the most part.
You now have a new CLI --background-mode
flag, which will disable the tray icon.
You should be able to reactivate the primary window / instance by just executing the application again, it should close the secondary instance and trigger the primary one.
Let me know if that is a usable solution for you.
Yup it works well. The background instance gets killed upon spawning a new normal instance. However, it doesn't stop you from spawning multiple background instances.
However, it doesn't stop you from spawning multiple background instances.
Are you sure you can spawn multiple background instances? It should not be possible, at least I cannot reproduce that.
The left window grep the process list for keyboard-center
, then I spawn another instance. The right window I grep the process list for keyboard-center
again. Both have the flags --background-mode
.
it should look like this when trying to start a secondary instance:
Yup, its not working. I'm not sure whats causing it, but I think it might be caused by a permisson issue or a bug in QT / python. Also i got the normal instance running while the background instance was still there:
yeah that is weird....but I don't think there is much I can do sadly, at least nothing obvious with no error message.
Are you on Wayland?
No Xorg, if you have any ideas on how to debug lemme know
Could you try again with the latest version? (If you even still use it that is)
From my testing, I sadly could not reproduce this issue, I tried Ubuntu and Manjaro on bare metal, there the singleton for triggering the primary instance works just fine.
It didn't work :(
returns false on my system. Could it be due to a missing library?
The singleton detection creates a local Unix socket in /tmp
to check if another instance is already running.
There is probably something weird going on that does not let one instance access the socket of the other. I might look into changing from a Unix Socket to a simple tcp one.
Maybe you have something blocking the access to /tmp or some kind of isolation going on?
I just tried running it as root
It auto launches from ~/.xprofile
Is there a better way to handle this? maybe systemd-service?
ok weird, looks like permission issues. Does a normal process not have write access to /tmp on your machine?
Is there a better way to handle this? maybe systemd-service?
No I am not going to go down the systemd rabbit hole again, there are good reasons why I moved away from that and switched to a tray icon.
I will look into bypassing file permissions by replacing the UNIX socket with a proper network socket. I will let you know once it is ready for testing.
ok weird, looks like permission issues. Does a normal process not have write access to /tmp on your machine?
it does. What happens is programs launched in .xprofile
have root permissions, but programs launched from shell/app-launcher will have the users permissons (assuming your default shell is your signed in user).
so when I login in keyboard-center --background-mode
is launched as root automatically. And when I run it normally, it can't detect because it doesn't have root permissions to read the unix socket. However, launching it as root works because it will have permission to read the socket.
And when I run it normally, it can't detect because it doesn't have root permissions to read the unix socket. However, launching it as root works because it will have permission to read the socket.
It should not matter though, since /tmp
should always have permissions set to 777, which means any process has full access.
It seems to be different on your system for some reason, as from my testing it did work running as normal user.
Can you check to what permissions your /tmp folder is set to?
/tmp
is 777. but inside, the files, have different permissions.
please retry with the latest version running as normal user
It Works!!!
nice awesome, glad to hear!
Feature request to hide tray icon
The idea I have is to pass a flag like '--hide-tray-icon' or '--daemon-mode'. This flag would just run the program as a daemon and wouldn't launch any GUI or tray icon. Any instance thats started after wouldn't start because it'll check to see if the daemon is running. This way you can avoid multiple processes being spawned.
It can be a setting advertised in the help menu or the README for power users who'd like to hide it. Additionally if anyone wants to change the settings, they can: