The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

How can I disable notifications when the screen locks and enable them again when unlocking?

asked 2015-03-24 21:33:25 +0000

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

I use dunst for notifications and xautolock/i3lock for a lockscreen. I'd like to disable notifications when the screen locks by using 'killall -SIGUSER1 dunst' and re-enable notifications with 'killall -SIGUSER2 dunst' when the screen is unlocked. In my i3 config I use 'exec xautolock -time 10 -locker "i3lock"', so I could add the 'killall -SIGUSR1 dunst' to that line and disable notifications, but how would I automatically re-enable them when the screen gets unlocked?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-03-24 21:47:38 +0000

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

See https://github.com/knopwob/dunst/issu...:

$ cat lock.sh
#!/bin/bash
# suspend message display
pkill -u "$USER" -USR1 dunst

# lock the screen
i3lock -n

# resume message display
pkill -u "$USER" -USR2 dunst
edit flag offensive delete link more

Comments

Exactly what I was after! thanks

curious_one gravatar imagecurious_one ( 2015-03-24 21:55:20 +0000 )edit

Does this really work? When I run `date; i3lock; date` in bash, the second `date` gets executed immediately. What you might want to do is to run `i3lock -n` instead. The `-n` option makes i3lock not fork. Compare the outputs of `date; i3lock; date` and `date; i3lock -n; date` to see the difference.

i3convert gravatar imagei3convert ( 2015-03-25 16:07:07 +0000 )edit

@i3convert you are correct. the -n is required for this to work correctly.

curious_one gravatar imagecurious_one ( 2015-05-29 14:58:38 +0000 )edit

Question Tools

Stats

Asked: 2015-03-24 21:33:25 +0000

Seen: 2,340 times

Last updated: Mar 26