Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Dunst invisible (blurred) when run with `sudo su $SUDO_USER -c`

Open spikespaz opened this issue 3 years ago • 3 comments

X: https://github.com/dunst-project/dunst/issues/1126

I have the following minimal example:

for i in 1 2 3 4; do                                                                              
  notify-send "Test $i" -h string:synchronous:disable-keyboard
  sleep 1
done

The notification shown does not replace the old one (as it should according to Dunst, and does work for my other scripts).

This is not the case if notify-send is run directly by the user.

I need to do this because the script's primary function requires superuser, and the script is marked as NOPASSWD in /etc/sudoers. Using sudo inline in the script only for the necessary commands is not an option.

What happens instead?

The first notification is shown correctly, any after that show up as a blurred rectangle in its place.

Here is a video where I first run the script, and then the notify-send commands individually, finally I copy and paste a contrived example from snippets of the script to demonstrate the commands should work as expected.

Note that for the first 30 seconds or so, I am waiting for the script to finish running. After that I start running things manually. Look in the top-right.

https://youtu.be/UvopfreWfa4

Here is the full script that I am working with:

#! /usr/bin/env bash

set -eu

# DISABLE_DEVICES=(
# 	# AT Translated Set 2 Keyboard
# 	/dev/input/event0
# 	# Sleep Button
# 	/dev/input/event9
# 	# Power Button
# 	/dev/input/event10
# 	# Lid Switch
# 	/dev/input/event8
# 	# ThinkPad Extra Buttons
# 	/dev/input/event15
# 	# SynPS/2 Synaptics Touchpad
# 	/dev/input/event19
# 	# TPPS/2 Elan TrackPoint
# 	/dev/input/event21
# )

# DISABLE_DEVICES=
: "${DISABLE_DURATION:=30}"
: "${NOTIFICATION_USER:="${SUDO_USER-$USER}"}"
: "${NOTIFICATION_COUNTDOWN:=28}"
: "${NOTIFICATION_TIMEOUT:=2000}"
: "${NOTIFICATION_TEXT_SIZE:=x-large}"
: "${NOTIFICATION_ICON_CATEGORY:=devices}"
: "${NOTIFICATION_ICON_NAME:=input-keyboard}"
: "${NOTIFICATION_URGENCY:=critical}"
: "${NOTIFICATION_TITLE:=Input/Keyboard}"

__NOTIFICATION_COUNTDOWN_TIMEOUT=2000

su "$NOTIFICATION_USER" -c "$(
cat <<- EOF
	notify-send \
		'$NOTIFICATION_TITLE' \
		"<b><span size='$NOTIFICATION_TEXT_SIZE'>Disabled</span></b>\\n${#DISABLE_DEVICES[@]} devices" \
		-u $NOTIFICATION_URGENCY \
		-t $NOTIFICATION_TIMEOUT \
		-c $NOTIFICATION_ICON_CATEGORY \
		-i $NOTIFICATION_ICON_NAME \
		-h string:synchronous:disable-keyboard
EOF
)"

pids=()

# for event in "${DISABLE_DEVICES[@]}"; do
# 	evtest --grab "$event" &> /dev/null &
# 	pids+=($!)
# done

sleep $((DISABLE_DURATION - NOTIFICATION_COUNTDOWN))

for i in $(seq 0 $NOTIFICATION_COUNTDOWN); do
	i=$((NOTIFICATION_COUNTDOWN - i))
	su "$NOTIFICATION_USER" -c "$(
	cat <<- EOF
		notify-send \
			'$NOTIFICATION_TITLE' \
			"Enabling ${#DISABLE_DEVICES[@]} devices in <b>$i seconds</b>" \
			-u $NOTIFICATION_URGENCY \
			-t $__NOTIFICATION_COUNTDOWN_TIMEOUT \
			-c $NOTIFICATION_ICON_CATEGORY \
			-i $NOTIFICATION_ICON_NAME \
			-h "int:value:$((100 * i / NOTIFICATION_COUNTDOWN))" \
			-h string:synchronous:disable-keyboard
	EOF
	)"
	sleep 1
done

# kill "${pids[@]}"

su "$NOTIFICATION_USER" -c "$(
cat <<- EOF
	notify-send \
		'$NOTIFICATION_TITLE' \
		"<b><span size='$NOTIFICATION_TEXT_SIZE'>Enabled</span></b>\\n${#DISABLE_DEVICES[@]} devices" \
		-u $NOTIFICATION_URGENCY \
		-t $NOTIFICATION_TIMEOUT \
		-c $NOTIFICATION_ICON_CATEGORY \
		-i $NOTIFICATION_ICON_NAME \
		-h string:synchronous:disable-keyboard
EOF
)"

spikespaz avatar Nov 13 '22 22:11 spikespaz

how is this a hyprland issue?

Is this somehow working on e.g. sway?

vaxerski avatar Nov 14 '22 01:11 vaxerski

I'm not sure if it's a hyprland issue. I don't have any other compositor set up, but I thought I might mention it in case you would tell me it's about xwayland and sessions or whatever something.

spikespaz avatar Nov 17 '22 04:11 spikespaz

doubt

vaxerski avatar Nov 17 '22 10:11 vaxerski

@vaxerski I think we can close this https://github.com/dunst-project/dunst/issues/1126

romanstingler avatar Jun 29 '23 21:06 romanstingler