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

Problems trying to automate the auto-toggle function #30

Open
kabe-inc opened this issue Feb 26, 2024 · 7 comments
Open

Problems trying to automate the auto-toggle function #30

kabe-inc opened this issue Feb 26, 2024 · 7 comments

Comments

@kabe-inc
Copy link

First off, thanks very much for creating and maintaining this project. I was very pleased to see the recent appearance of the auto-toggle feature, but I am experiencing something teething problems when trying to automate it and am hoping you might be to enlighten(!) me.

The auto-toggle function seems to work perfectly when run manually in a terminal, but seeing as I don't want to have to do that at every startup I tried to create a systemd service instead, using the following config:

[Unit]
Description=Logitech Litra Service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/litra auto-toggle
WorkingDirectory=/usr/local/bin/
StandardOutput=inherit
StandardError=inherit
SyslogIdentifier=mybinaryprogram
User=root
Group=root

[Install]
WantedBy=multi-user.target`

This method seems to work at first glance but I quickly noticed that the light is being auto-toggled on even when no camera device is active, like the service is picking up on a false positive activation event (or something similar).

Can you spot anything I'm doing wrong, or would you suggest another way to go about this?

Many thanks!

System: EndeavourOS
Kernel: arch 6.6.18-1-lts
Light: Litra Glow
Camera: Logitech C920

@timrogers
Copy link
Owner

@Holzhaus I think you'll be in the best position to help with this ❤️

@Holzhaus
Copy link
Contributor

You say it worked perfectly when running on the terminal. As which user did you run it? As root or as your regular user? If the latter is the case, try to replace the User=root in the systemd config with your username.

Currently, the auto-toggle command monitors all accesses to /dev/video* devices. My guess would be that your local user lacks permission to do that for some device files, but root has that permission, and that these files cause the false positives.

One easy fix could be to add a command line argument where you specify a video device. That way other video devices would be ignored. But I'm not sure if the video devices have a predictable order a cross restarts. Maybe some way to specify a video device by serial number or similar would be preferable.

@kabe-inc
Copy link
Author

kabe-inc commented Feb 27, 2024

Thanks for the reply.

As which user did you run it? As root or as your regular user? If the latter is the case, try to replace the User=root in the systemd config with your username.

I ran it under my admin account, using sudo. I put the user as root in the config because running the command manually from the terminal under my user account without sudo gives a Permission denied error. I assume that this would also be the case if I amended the User=root in the config to User=myusername>?

One easy fix could be to add a command line argument where you specify a video device. That way other video devices would be ignored. But I'm not sure if the video devices have a predictable order a cross restarts. Maybe some way to specify a video device by serial number or similar would be preferable.

This sounds like a good idea to me. My latop has a built-in webcam (which I never use) in addition to the USB webcam, so being able to isolate specify the Logitech via a command would be a nifty feature.

@Holzhaus
Copy link
Contributor

Holzhaus commented Mar 17, 2024

Please have a look at #39 and let me know if this works for your use-case. IBM not sure that the device paths are actually stable across restarts, this would also make sense to check.

To find the correct path you can use v4l-ctl --list-devices.

@Holzhaus
Copy link
Contributor

Regarding the permission issue, check the README. If you install the udev rules you should be able to run litra as regular user:

https://github.com/timrogers/litra-rs?tab=readme-ov-file#configuring-udev-permissions-on-linux

@kabe-inc
Copy link
Author

kabe-inc commented Mar 19, 2024

Adding the udev rules worked a treat, thanks.

So with the #39 build, I should add LITRA_VIDEO_DEVICE_PATH=/dev/video2 as an environment variable and then run auto-toggle with no arguments, correct? (FWIW, the device path seems stable for my machine at least.)

@kabe-inc
Copy link
Author

As a follow-up, I've found that the test build works just the same as the latest release for my purposes.

I've actually found that running 'auto-toggle in the background via a startup bash script works better than running it as a systemd service, anyway, so that's what I'd recommend to anyone else trying to achieve the same thing.

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

3 participants