Skip to content
/ xpub Public
forked from Ventto/xpub

POSIX Shell script to get user's display environment variables of any TTY from anywhere.

License

Notifications You must be signed in to change notification settings

janza/xpub

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Xpub

License

"Xpub is a Shell script to get user's display environment variables of any X graphical session from anywhere."

Perks

  • No requirement: POSIX-compliant.
  • Painless: do not care about which display environment variables to set anymore.
  • Runs x-tasks in udevrules: no more script to run one graphical command.
  • Useful: runs graphical tasks from high-privileged users and limited environments.

Installation

  • Package (AUR)
$ yaourt -S xpub
  • Manually
$ git clone https://github.com/Ventto/xpub.git
$ cd xpub
$ chmod +x src/xpub.sh

Usage

Usage: xpub [OPTION]...

  -h:   Prints this help and exits.
  -v:   Prints the version and exits.
  -t:   Prints the logged user and its display environment variables from a graphical-session TTY
        or from the current one if no argument.

Examples

$ xpub
TTY=tty1
XUSER=user1
XAUTHORITY=/home/user1/.Xauthority    (not printed if XWayland)
DISPLAY=:0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1022/bus

From Udev rules :

IMPORT{program}="/usr/bin/xpub", \
RUN+="/bin/su $env{XUSER} -c '/usr/bin/notify-send Hello'"

After editing your rules, you may need to run udevadm control --reload-rules.

From command-line as root :

$ export $(xpub) ; su "${XUSER}" -c 'notify-send Hello'

From Shell scripts :

xenv=$(xpub 2>/tmp/xpub.log)

if [ $# -ne 0 ]; then
    exit 1
else
    export ${xenv}
fi

su "${XUSER}" -c "notify-send Hello"

About

POSIX Shell script to get user's display environment variables of any TTY from anywhere.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%