From 2383c5b6cd36f08a11129b72bbd733fbdfee8e34 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Tue, 11 Jun 2019 14:00:09 +1000 Subject: [PATCH] Removed user-hook-sleep and xuserrun --- bin/xuserrun | 62 ---------------------- etc/systemd/system/user-hook-sleep.service | 10 ---- etc/udev/rules.d/10-monitor.rules | 1 - 3 files changed, 73 deletions(-) delete mode 100755 bin/xuserrun delete mode 100644 etc/systemd/system/user-hook-sleep.service delete mode 100644 etc/udev/rules.d/10-monitor.rules diff --git a/bin/xuserrun b/bin/xuserrun deleted file mode 100755 index d6909ce..0000000 --- a/bin/xuserrun +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# vim:ts=2:sts=2:sw=2 - -# -# Run a command as the currently active X11 user -# - -seat="seat0" - -# determine location of loginctl -LOGINCTL=$(command -v loginctl || command -v systemd-loginctl) -if [[ -e LOGINCTL ]]; then - echo "Error: Unable to find loginctl executable" - exit 1 -fi - -get_session_info() { - local session="$1" - local varname="$2" - local IFS=$'\n' - eval declare -Ag $varname - for row in $(loginctl show-session "$session"); do - key="$(echo "${row}"|cut -d= -f1)" - val="$(echo "${row}"|cut -d= -f2-)" - eval ${varname}[\"${key}\"]=\"${val}\" - done -} - -escape() { - for arg in "$@" ; do - printf "%q " "$arg"; - done; -} - -session_list="$(loginctl --no-legend | grep "$seat" | awk '{print $1}')" -found_active_session="" -for session in $session_list; do - get_session_info "$session" session_info - if [[ "${session_info[Active]}" = "yes" ]]; then - found_active_session="yes" - break - fi -done -if [ -z "${found_active_session}" ]; then - echo "Error: Unable to determine active session" - exit 1 -fi - -if [[ "${session_info[Type]}" != "x11" ]]; then - echo "Error: Active session is not x11" - exit 2 -fi - -current_user="$(id -u -n)" - -if [[ ${current_user} == ${session_info[Name]} ]]; then - # already correct user, no need to su - DISPLAY="${session_info[Display]}" "$@" -else - # run command as user - DISPLAY="${session_info[Display]}" su -c - "${session_info[Name]}" "$(escape "$@")" -fi diff --git a/etc/systemd/system/user-hook-sleep.service b/etc/systemd/system/user-hook-sleep.service deleted file mode 100644 index 4411c46..0000000 --- a/etc/systemd/system/user-hook-sleep.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=User hook for sleep action -Before=sleep.target - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/xuserrun bash -c '. ~/.bashrc && ~/.hooks/sleep' - -[Install] -WantedBy=sleep.target diff --git a/etc/udev/rules.d/10-monitor.rules b/etc/udev/rules.d/10-monitor.rules deleted file mode 100644 index c7e8747..0000000 --- a/etc/udev/rules.d/10-monitor.rules +++ /dev/null @@ -1 +0,0 @@ -KERNEL=="card0", SUBSYSTEM=="drm" RUN+="/usr/local/bin/xuserrun bash -c '. ~/.bashrc && ~/.hooks/monitor'" -- 2.39.2