Let's say I want to run in one workspace
sleep 10 && zenity --warning --text 'Wake up!'
and then I work on other stuffs in a different workspace. How do I get this zenity window pop up in whichever workspace I'm in instead of the original workspace I typed the command in? Or is it easier to have it pop up in all the workspaces?
i haven't found an elegant way to have such a dialogue pop up in all workspaces simultaneously (multiplex), but found after some fiddling around that wmctrl
lets you set a windows position, size and (most importantly) to have it raise it on the currently active workspace.
in my specific case i needed this to work also for notifications scheduled through cron
and at
which requires a slightly different approach as shown in the following shellscript:
#!/usr/bin/env bash
## demo of how to raise a zenity-notification on the active workspace
## license: MIT copyright: antiplex
export DISPLAY=:0.0
## start wmctrl with a delay in subshell
(sleep 1; wmctrl -r TimedWarning -e 0,40,30,-1,-1; wmctrl -R TimedWarning) &
## launch a zenity dialogue of your choice
zenity --warning --title="TimedWarning" --text="Time is up!" --display=:0.0
for some weird reason, the above script also pulls the terminal-window from which i scheduled the execution to the active workspace when scheduling with at
and when the terminal is still open.
here is another variant using the notification daemon / libnotify (check package libnotify-bin
on debian-based systems) that won't also raise the terminal on the active workspace:
#!/usr/bin/env bash
## demo of how to raise a non-volatile libnotify-notification
## on the currently active workspace
## license: MIT copyright: antiplex
export DISPLAY=:0.0
## critical notifications with expire time 0 need to be manually confirmed
notify-send --expire-time 0 -u critical TimedWarning "Time is up!"
## rename window title as notify-send would name all its windows 'notify-send'
wmctrl -r notify-send -T TimedWarning
## set new position in upper left corner, keeping the windows size
wmctrl -r TimedWarning -e "0,40,30,-1,-1"
## raise window on currently active workspace
wmctrl -R TimedWarning