You are not logged in.
Hello.
I created a simple .timer file with these inside:
[Unit]
Description=Script to remind me backup every month
[Timer]
# Time to wait after booting before we run first time
OnBootSec=10min
# Time between running each consecutive time
OnUnitActiveSec=1minute
Unit=timer_backup.service
Persistent=true
[Install]
WantedBy=multi-user.target
and a .service file with:
[Unit]
Description=Timer script to remind me for backup
[Service]
Type=simple
ExecStart=/path/to/bu.sh
the bu.sh has
notify-send -u critical -t 999999999 -c backup "System backup reminder" "It's time to backup the whole system"
The problem is that it never visualize the notify box.
How can i run a X application in the activated user monitor ? Also tried to use xuserrun but it couldn't find any enable screen although the loginctl returns the session of my user.
Offline
1 - The simple way is to start a script with a while/loop+sleep from your running graphical session.
2 - If you insist in using systemd services, than maybe the command "wall" would be handy too (assuming your notification daemon will catch wall messages)
3 - If you absolutely want to use your method, then some additional work is needed.
Take a look at this: https://aur.archlinux.org/packages/batterylife
I strongly suggest 1.
If you need everybody in your system to get the reminder, then i still strongly suggest 2
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
You have to tell it where to send the notification to...
Environment=DISPLAY=:0
Offline
I changed the script to that but doesn't work.
DISPLAY=:0 notify-send -u critical -t 999999999 -c backup "System backup reminder" "It's time to backup the whole system"
Also i add the line
Environment=DISPLAY=:0
in .service file and still the same.
With
wall notify-send "test"
i hear just a 'bip' from the machine.
Offline
The display envinroment variable itself is not enough to send a notification.
You need to know the dbus session the daemon is registered to as well as the user logged to (which?) display number.
I linked you batterylife package for that reason, it takes care of guessing those informations before sending the notification.
It works for gnome session, but it is adaptable to kde or any DE you're using with some dirty hacking (the scriipt itself is a little hacky).
As for the wall command,
"wall" is a way to send messages to all users logged in, so that:
wall make the backup
will write "make the backup" to every logged users terminal.
Under kde, that message is intercepted by its notification daemon, and a notification pops up saying "make a backup".
I don't know what your de is, so you should check if there is a way to catch those "wall" broadcast messages.
The main question remains...
why do you want to use a service to perform a user/desktop task?
The easy and simple way is to autostart a script as the user logs in...
Last edited by kokoko3k (2014-11-03 12:19:31)
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
@kokoko3k and how would you make the command in script to run every x minutes while logged in (X) using the loop + sleep or while and meanhile keep running in the background? (not even me understood what i meant but I hope you do)
Offline
@bittermint, it is a bit offtopic, but anyway...
your Desktop environment will probably executes an autostart script file.
Then it is only a matter of compiling it with something like:
My autostart script:
#!/bin/bash
something
something other
MyBackgroundProcess.sh &
...
something
Any MyBackgroundProcess.sh would be like this:
while true ; do
MyPeriodicProcess
sleep 60
done
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline