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

Linux support #22

Merged
merged 4 commits into from
Sep 20, 2020
Merged

Linux support #22

merged 4 commits into from
Sep 20, 2020

Conversation

haimgel
Copy link
Owner

@haimgel haimgel commented Sep 10, 2020

Some preliminary Linux support

Things that seem to be working

The app detected USB changes and changed display inputs based on that. I tested this on Raspberry Pi 3, don't have a normal Linux desktop.

Things that do not work / missing

  • "Wake up display before switching" functionality is not implemented.
  • Documentation: DDC on Linux seems to be more finicky, I had to add my user to the i2c group for the app to work.
  • Config file location does not make much sense, should also check in /etc/
  • Log file location does not make sense either, should just log to syslog.
  • Should package this as .deb or .rpm and include a Systemd wrapper ideally.

Ref: #22

@haimgel haimgel self-assigned this Sep 10, 2020
@haimgel haimgel linked an issue Sep 10, 2020 that may be closed by this pull request
@haimgel haimgel mentioned this pull request Sep 10, 2020
@universal
Copy link
Contributor

trying this out under ubuntu 20.04/popos, and for now:

  • needs libudev-dev package on linux
  • need to create ```~/.config/display-switch.ini``
  • no i2c group on ubuntu 20.04/popos -> sudo chown `whoami` /dev/i2c-10 (for me, used ddcontrol -p to figure out i2c device)

switching usb device away and back to this machine:

11:23:26 [INFO] Display '22794' #0 is currently set to 0xf
11:23:35 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "0bda:0411"
11:23:35 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "045e:082a"
11:23:35 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "046d:0891"
11:23:36 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "046d:c33c"
11:23:36 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "0bda:5411"
11:23:43 [DEBUG] (1) display_switch::app: Detected device change. Added device: "0bda:5411"
11:23:44 [DEBUG] (1) display_switch::app: Detected device change. Added device: "0bda:0411"
11:23:45 [DEBUG] (1) display_switch::app: Detected device change. Added device: "045e:082a"
11:23:45 [DEBUG] (1) display_switch::app: Detected device change. Added device: "046d:0891"
11:23:45 [DEBUG] (1) display_switch::app: Detected device change. Added device: "046d:c33c"
11:23:45 [INFO] Detected device we're looking for "046d:c33c"
11:23:45 [DEBUG] (1) display_switch::platform::display_control_ddc_hi: Setting display ''22794' #0' to 0xf
11:23:45 [INFO] Display '22794' #0 set to 0xf

looks good and works for me just fine, as I've only one display directly connected and the other is daisy-chained via displayport :-)

@haimgel
Copy link
Owner Author

haimgel commented Sep 14, 2020

@universal thanks for testing! Did you happen to notice the permissions / ownership of /dev/i2c-* before you changed it?

We'll need a more permanent solution as this chown is not going to survive a reboot.

@universal
Copy link
Contributor

yep, should be root:root . there are guides for creating udev rules and adding a new usergroup that would provide a more permanent solution. I have been busy with other stuff, but I will crosscheck if it stays across a reboot. I suspect kernel-updates potentially also change the device, but will check that as well.

@universal
Copy link
Contributor

so I just checked:

  • owner is root:root
  • changing owner does not persist (as predicted/expected)
  • ubuntu/popos don't appear to have a dedicated i2c group by default
  • https://lexruee.ch/setting-i2c-permissions-for-non-root-users.html -- this appears to be a straightforward guide to adding such a group
  • otherwise: the startup script might take care of the chown, not sure about the sudo powers required/possibility of limiting access... but might be fine for a local, single user install :-)

@haimgel
Copy link
Owner Author

haimgel commented Sep 20, 2020

@universal thanks for checking, makes sense!

I think going forward, the best approach would be building a deb / rpm package to install the app system-wide, with the config in /etc, logging to system logs normally and running under root with systemd. This would sidestep the whole permissions issue completely.

I created #26, #27, #28, that all together should make Linux support more decent, but this PR seems to work good enough for now, will merge it.

@haimgel haimgel merged commit 460cda7 into master Sep 20, 2020
@haimgel haimgel deleted the feature/linux-support branch September 20, 2020 15:41
@tdryer
Copy link

tdryer commented Nov 1, 2020

ubuntu/popos don't appear to have a dedicated i2c group by default

You can get an i2c group on Ubuntu by installing the i2c-tools package, which comes with a udev rule.

Then you just need to add your user to the group, and log out for it to take effect:

sudo usermod $USER -aG i2c

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

Successfully merging this pull request may close these issues.

Linux support?
3 participants