Skip to content
/ xpub Public

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

Ventto/xpub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Xpub

License Vote for xpub

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

Perks

  • No requirement: POSIX-compliant.
  • Omniscient: Provides X environment variables of any session from any user.
  • Usefull: Run graphical commands from udevrules (see below).
  • Extra: Display graphical command on a specific session.
  • Support: XWayland users, keep calm.

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 [-t TTY]

Without option, prints the X session information of the current user.

  -h:   Prints this help and exits.
  -v:   Prints the version and exits.
  -t:   prints the current TTY's user X session information.

Examples

From terminal

sudo is required.

  • Get information of your current session:
$ xpub
TTY=tty2
XUSER=alice
XAUTHORITY=/home/alice/.Xauthority
DISPLAY=:0
DBUS_SESSION_BUS_ADDRESS=/path
  • Get information of a specific session:
$ xpub -t tty2
XUSER=alice
XAUTHORITY=/home/alice/.Xauthority
DISPLAY=:0
DBUS_SESSION_BUS_ADDRESS=/path

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.

For root

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

Shell scripts

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

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

su "${XUSER}" -c "/usr/bin/notify-send Hello"

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages