Last active
March 29, 2021 08:02
-
-
Save GluTbl/ecd61f3f8cca802030bc05772c28f621 to your computer and use it in GitHub Desktop.
[sudo running in as user mode] #linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Detect the name of the display in use | |
display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" | |
#Detect the user using such display | |
user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1) | |
#Detect the id of the user | |
uid=$(id -u $user) | |
sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus aplay "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment