1

I can not solve the problem with pactl, I have some pactl comand in my sh file and I must start this file as root. But pactl comand do not work with root. I try to write sudo -u $USER and a lot of differnt variants with differnt groups and users but it still does not work

  • Why must you run it as root? Pulseaudio runs as your user. – muru Mar 08 '21 at 13:13
  • Because of some reason I should start sh file with sudo, I know that pactl command work only with user, but I am trying to make them work in sudo sh file, how I said a already try to change user by sudo -u some_user for pactl command and change group sudo -g some_group, but it does not work – Иван Демьянов Mar 08 '21 at 14:09
  • What reason? A simple sudo -u some_user pactl weon't work - PulseAudio uses DBus, and you'd need to use dbus-launch or otherwise guide pactl to the existing DBus session for it work. – muru Mar 08 '21 at 14:29
  • Is it possible to do from sh file? If it will not be hard for you, can you show how to do this, I am beginner in Linux – Иван Демьянов Mar 08 '21 at 14:58
  • Or from python subprocess, when python file start as root (because of keyboard library it work only with root) – Иван Демьянов Mar 08 '21 at 15:01
  • You might need to run something like the command in https://askubuntu.com/a/1134457/158442. Are you sure the keyboard library needs root? All it probably needs is USB device access and that can be granted via the plugdev group. – muru Mar 08 '21 at 15:11
  • I read this in library docs https://pypi.org/project/keyboard/ . I do not find another solution to catch all keyboard actions – Иван Демьянов Mar 08 '21 at 15:27
  • It says it needs root because it tries to read /dev/input/input*. Run ls -l /dev/input/input* to which group those files being to. I don't have a system on hand to check, but I think they should be owned by plugdev like in https://unix.stackexchange.com/a/242224/70524 – muru Mar 08 '21 at 15:32

0 Answers0