Hi! I currently depend on optimus-manager for fast switching between intelgpu and nvidia graphics. however, the service for that is written for systemd. how would i go rewriting that service for s6? thx in advance!
Hello. That's package is from AUR, I've checked the code a bit from github and it does not seems that has an hard dependency on systemd so you might have to write the script for s6. In this repo (https://gitea.artixlinux.org/artixlinux/packages-s6) there are a lot of s6 scripts and this website (https://skarnet.org/software/s6/servicedir.html) is the official documentation.
sorry for the late reply. only recently got free time to do this now, but i have some questions.
this is what the .service file looks like:
[Unit]
Description=Optimus Manager Commands Daemon
Before=display-manager.service
[Service]
ExecStartPre=-/usr/bin/python3 -u -m optimus_manager.hooks.pre_daemon_start
ExecStartPre=-/usr/bin/python3 -u -m optimus_manager.hooks.pre_xorg_start
ExecStart=/usr/bin/python3 -u -m optimus_manager.daemon
ExecStopPost=/usr/bin/python3 -u -m optimus_manager.hooks.post_daemon_stop
[Install]
WantedBy=graphical.target
i'm kinda confused about the "Before=display-manager.service" and the "ExecStartPre" arguments. how do i tell s6 to start "pre services" before the main service and how to i tell it to start these services before the display manager service?
On how to do before you can sed this service to add to whichever displaymanager service’s dependencies file, you use. On the execpre you can just write the exec that needs to be ran before the main exec line.
i'm a bit confused about the display manager part. is the display manager service the login manager (like lightdm or sddm) or is it some other service?
Correct, like sddm, lightdm, etc
Unfortunately, s6/s6-rc doesn't have a direct "Before=" equivalent. You can tell services to start
after some other service though by using a
dependencies file. See the s6-rc documentation (https://skarnet.org/software/s6-rc/s6-rc-compile.html).
ok, so i'm done writing the service, but how do i add it to the s6 compiled database? the documentation doesnt seem to tell how
btw, how do i attach a file here? i dont see an "attach file" button anywhere
Therre is a "REPLY" button on the left right side.
Press it and you will be welcomed with new page in wwhich you can see the file dialog
"Add files by dragging & dropping or selecting them"
Best way is to write a pkgbuild to install it so it gets compiled and added to database.
Found the script that does the "compile". Make sure you add the service script inside a new dir in /etc/s6/sv and run
sh /usr/share/libalpm/scripts/s6-rc-db-update-hook
here it is if anyone wants to test it :)
oh, and don't forget to add optimus-manager-daemon service as dependency of lightdm or sddm
for some reason i'm getting this:
artix:[artix]:~$ optimus-manager --switch nvidia
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 177, in activate_name_owner
return self.get_name_owner(bus_name)
File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 361, in get_name_owner
return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.systemd1': no such name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/optimus-manager", line 33, in <module>
sys.exit(load_entry_point('optimus-manager==1.3', 'console_scripts', 'optimus-manager')())
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 55, in main
_gpu_switch(config, args.switch, args.no_confirm)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 69, in _gpu_switch
run_switch_checks(config, switch_mode)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 10, in run_switch_checks
_check_daemon_active()
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 25, in _check_daemon_active
if not checks.is_daemon_active():
File "/usr/lib/python3.8/site-packages/optimus_manager/checks.py", line 108, in is_daemon_active
return _is_service_active("optimus-manager")
File "/usr/lib/python3.8/site-packages/optimus_manager/checks.py", line 139, in _is_service_active
return _is_service_active_dbus(system_bus, service_name)
File "/usr/lib/python3.8/site-packages/optimus_manager/checks.py", line 143, in _is_service_active_dbus
systemd = system_bus.get_object("org.freedesktop.systemd1", "/org/freedesktop/systemd1")
File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 241, in get_object
return self.ProxyObjectClass(self, bus_name, object_path,
File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 250, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 182, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 277, in start_service_by_name
return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.systemd1 was not provided by any .service files
artix:[artix]:~$
any ideas how i could fix it?
You can try adding this patch during build of optimus-manager, not the s6 script : https://termbin.com/dq1x
Though I don't know if it will work, but it's worth a try
bit of a dumb question but how do i apply a patch? i'm not really experienced with git. sorry
Here I edited the pkgbuild and included the patch, all you got to do is extract it, and run makepkg -si
did you attached the file? i dont see a zip file
Sorry, thought I attached a link. http://www.filedropper.com/optimus-managertar
i think the archive's corrupt
sha1sum: 513f0107290867db06a563906f82b2678cf7420e optimus-manager.tar.gz
# tar -xf optimus-manager.tar.gz
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
could you upload it again?
http://www.filedropper.com/optimus-manager
well, the systemd error is gone (thx for the patch!), but a new one came up:
artix:[artix]:~$ optimus-manager --status
Optimus Manager (Client) version 1.3
Current GPU mode : intel
GPU mode requested for next login : no change
GPU at startup : intel
Temporary config path: no
artix:[artix]:~$ optimus-manager --switch nvidia
Traceback (most recent call last):
File "/usr/bin/optimus-manager", line 33, in <module>
sys.exit(load_entry_point('optimus-manager==1.3', 'console_scripts', 'optimus-manager')())
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 55, in main
_gpu_switch(config, args.switch, args.no_confirm)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 69, in _gpu_switch
run_switch_checks(config, switch_mode)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 10, in run_switch_checks
_check_daemon_active()
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 25, in _check_daemon_active
if not checks.is_daemon_active():
File "/usr/lib/python3.8/site-packages/optimus_manager/checks.py", line 108, in is_daemon_active
return _is_service_active("optimus-manager")
NameError: name '_is_service_active' is not defined
artix:[artix]:~$
well, you should define some fake isserviceactive function or disable all code using it.
I would search for all uses of it and tried to remove it, since it is mess.
Try http://www.filedropper.com/optimus-manager_1
Did it work?
nope, still doesn't work
(sorry for late reply, was busy with other things)
artix:[artix]:~$ optimus-manager --status
Optimus Manager (Client) version 1.3
Current GPU mode : intel
GPU mode requested for next login : no change
GPU at startup : intel
Temporary config path: no
artix:[artix]:~$ optimus-manager --switch nvidia
Traceback (most recent call last):
File "/usr/bin/optimus-manager", line 33, in <module>
sys.exit(load_entry_point('optimus-manager==1.3', 'console_scripts', 'optimus-manager')())
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 55, in main
_gpu_switch(config, args.switch, args.no_confirm)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 69, in _gpu_switch
run_switch_checks(config, switch_mode)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 10, in run_switch_checks
_check_daemon_active()
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 25, in _check_daemon_active
if not checks.is_daemon_active():
AttributeError: module 'optimus_manager.checks' has no attribute 'is_daemon_active'
artix:[artix]:~$
Here is another try http://www.filedropper.com/optimus-manager_2
If this doesn't work I am unsure what more can be done
nope, but we're getting closer. looks like the author put in a lot of checks
artix:[artix]:~$ optimus-manager --status
Optimus Manager (Client) version 1.3
Current GPU mode : intel
GPU mode requested for next login : no change
GPU at startup : intel
Temporary config path: no
artix:[artix]:~$ optimus-manager --switch nvidia
Traceback (most recent call last):
File "/usr/bin/optimus-manager", line 33, in <module>
sys.exit(load_entry_point('optimus-manager==1.3', 'console_scripts', 'optimus-manager')())
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 55, in main
_gpu_switch(config, args.switch, args.no_confirm)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/__init__.py", line 69, in _gpu_switch
run_switch_checks(config, switch_mode)
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 13, in run_switch_checks
_check_patched_GDM()
File "/usr/lib/python3.8/site-packages/optimus_manager/client/client_checks.py", line 54, in _check_patched_GDM
dm_name = checks.get_current_display_manager()
AttributeError: module 'optimus_manager.checks' has no attribute 'get_current_display_manager'
artix:[artix]:~$
I haven't looked very closely at this but the dbus 'org.freedesktop.systemd1' part actually should have worked if you have elogind running. elogind exposes this very same API and is able to receive that dbus message. Now this is done in python so I don't know if there's any limitation from python-dbus. I wouldn't think so but I've never looked at it in detail. It works in C however.
just checked. i already have elogind-log and elogind-srv running on startup. maybe something else is the problem? not so sure myself either
I'm going to guess it's probably a python-dbus limitation then. At least with that particular function. Many programs send messages to "org.freedesktop.systemd1" which works without any problems with elogind. Of course, these programs use different dbus implementations (all in C) which is the major difference. I do not know what python-dbus does here exactly with that particular function call.
Just wondering, how's the progress of the Optimus Manager S6 rewrite?
I love using OM as it has the better performance/framerate compared to Bumblebee.