Skip to content
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

Run as Windows Service #17

Closed
cocowalla opened this issue Sep 8, 2020 · 9 comments
Closed

Run as Windows Service #17

cocowalla opened this issue Sep 8, 2020 · 9 comments

Comments

@cocowalla
Copy link
Contributor

Firstly, thanks for this - it works great with my cheap USB switch!

Similarly to #5, I don't want to have display-switch.exe visible in the task bar all the time, taking up space. I understand you prefer not to clutter the tray bar (altho IMO that would be preferable to cluttering the task bar 😄) - could display-switch run as a Windows Service instead?

I know absolutely nothing about DDC/CI, so I don't know if perhaps display-switch needs access to the desktop session, or if there might be other barriers.

@haimgel
Copy link
Owner

haimgel commented Sep 8, 2020

Cluttering the task bar

This is actually a regression in the current master comparing to 0.1.0! It should not do that, it should run silently without a console window visible (at least by default).

@haimgel haimgel closed this as completed in 0d83cf6 Sep 8, 2020
@haimgel
Copy link
Owner

haimgel commented Sep 8, 2020

Furthermore about "run as a windows service": I'd prefer this to require as few permissions as possible, to allow this to be run on corp computers where the user does not necessarily have admin rights. I don't think there's a great value in this, comparing to just dropping the exe into the startup folder and forget about it.

@cocowalla
Copy link
Contributor Author

Furthermore about "run as a windows service": I'd prefer this to require as few permissions as possible, to allow this to be run on corp computers where the user does not necessarily have admin rights. I don't think there's a great value in this, comparing to just dropping the exe into the startup folder and forget about it.

I have such corp computers, so fully agree as long as no window is shown 👍

@cocowalla
Copy link
Contributor Author

@haimgel I don't know if you want to re-open this issue, but after using display-switch for a while there is one niggling issue I have, which is related to it running as a console app.

Because display-switch runs as a console app in a user session, you have to login once to the computer before it will switch automatically.

This is because before you login, display-switch doesn't start. If instead it ran as a Windows service, it would start when the computer booted.

@haimgel haimgel reopened this Nov 17, 2020
@haimgel
Copy link
Owner

haimgel commented Nov 17, 2020

Yeah, this is a valid concern. As long as this "service mode" is optional, it could be a useful thing to have. I won't have time for this right now, but I'll keep the ticket open.

@oddbjornkvalsund
Copy link

A third party solution to this could be to use https://github.com/winsw/winsw as a service wrapper. I've used this for years (in a different context) and it works great!

@cocowalla
Copy link
Contributor Author

@oddbjornkvalsund I tried this just the other day, but unfortunately it doesn't seem to work. When running as a service, I can see from the logs that display-switch does detect the USB changes, but it logs this with regards to displays:

[ERROR] Did not detect any DDC-compatible displays

I tried even running the service as LocalSystem, and also tried allowing it to interact with the desktop, but get the same result, whether logged in already or not.

@oddbjornkvalsund
Copy link

@cocowalla Ah, I haven't tried using winsw with display-switch unfortunately, so I have no first hand experience to offer, but did you try running the service as your personal user? I'm not sure if that's even possible...

@LegendaryB
Copy link

LegendaryB commented Jan 28, 2022

@oddbjornkvalsund I tried this just the other day, but unfortunately it doesn't seem to work. When running as a service, I can see from the logs that display-switch does detect the USB changes, but it logs this with regards to displays:

[ERROR] Did not detect any DDC-compatible displays

I tried even running the service as LocalSystem, and also tried allowing it to interact with the desktop, but get the same result, whether logged in already or not.

The problem could be that by default windows services are not allowed to access the desktop. You need to enable that explicitly in the service control panel. Maybe some API calls fail because of that. You could try it out. Not sure if this is the solution

@haimgel haimgel closed this as completed Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants