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

OpenRC support? #62

Open
harakiru opened this issue May 1, 2021 · 5 comments
Open

OpenRC support? #62

harakiru opened this issue May 1, 2021 · 5 comments
Labels
feature A new feature

Comments

@harakiru
Copy link

harakiru commented May 1, 2021

I was wondering if it was possible to make a OpenRC compatible version of this. I think people who use distros without systemd would benefit greatly from this.

@harakiru
Copy link
Author

harakiru commented May 1, 2021

I haven't tested it yet but perhaps something like this could be used:

#!/sbin/openrc-run

name=$RC_SVCNAME
description="EGPU Service"
command="/usr/bin/egpu-switcher"
command_args="switch auto"

depend() {
	after bolt 
	before display-manager 
} 

@hertg
Copy link
Owner

hertg commented May 2, 2021

I'd be open to add OpenRC support sometime, but I am not familiar with it at all. If you could test the example configuration you posted and update it if necessary, I can add this to the backlog.

One hint: I struggled with the SystemD config at the beginning because specifying "before=display-manager" wasn't enough to make sure that the display-manager only starts after egpu-switcher exits (display-manager started after egpu-switcher, but it didn't wait for it to finish). Specifying the systemD service to be of type=oneshot was necessary to make display-manager wait for the epgu-switcher to actually complete, otherwise race conditions can occurr (some background info: #16). It would be great if you could check if something similar is necessary in OpenRC.

Adding OpenRC support would require some code changes in the main script though. My main focus now is how I could rewrite the script to extends its functionality for general thunderbolt devices (not just eGPUs) and I'm working on a prototype in Rust (see discussion #58). Because of that, feature-additions to the bash script aren't my main focus right now, and I can't guarantee any time-frame when this would be implemented. I would welcome a PR though :)

@harakiru
Copy link
Author

harakiru commented May 2, 2021

Understood. I'm afraid i dont know anything about thunderbolt since i use expresscard. However i downloaded and ran the script and it works great as it is. Seems like the only issue is that it cant place and start the systemd service file (since there is no such thing in a openrc system) otherwise it successfully switches my system to the egpu. I'll try to work on a PR when i have some time and hopefully we can add openrc support sometime soon.

@hertg
Copy link
Owner

hertg commented May 2, 2021

I'm afraid i dont know anything about thunderbolt since i use expresscard

Thanks a lot for pointing that out, I wasn't actually aware that people might use the script with non-Thunderbolt external video devices.

I'll try to work on a PR when i have some time and hopefully we can add openrc support sometime soon.

Sounds great! I think the "only" thing to change in the script is the logic where it creates the systemd service. So instead of creating the systemD service directly, it should check whether the init system is systemD or OpenRC, and then apply the according configuration.

Most important lines are probably here: https://github.com/hertg/egpu-switcher/blob/master/egpu-switcher#L335-L338
and here https://github.com/hertg/egpu-switcher/blob/master/egpu-switcher#L501-L510

@hertg
Copy link
Owner

hertg commented Sep 14, 2022

With the recent rewrite, I took this issue into consideration and tried to abstract away anything systemd related behind an interface. So implementing this might be pretty straightforward. But since I am unfamiliar with OpenRC and since this probably is a niche use-case I don't have any plans on actually implementing this. I'm happy to accept PRs though.

@hertg hertg added the feature A new feature label Sep 14, 2022
@hertg hertg removed their assignment Oct 8, 2022
@hertg hertg moved this to Triage in egpu-switcher Mar 2, 2023
@hertg hertg moved this from Triage to Hold in egpu-switcher Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
Status: Hold
Development

No branches or pull requests

2 participants