Dotfiles/Scripts/displayer

16 lines
558 B
Bash
Executable File

#!/bin/bash
# Provides the display and user to command $1 and passes all other parameters ($2, ...) to $1
#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 "$@"
sudo -u jeanclaude DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus "$@"