basically when i close an application i want to run a script / command
for example when i launch vlc ,
when i close the app i to write to a file some thing like
vlc opened $dd::mm::ss
basically when i close an application i want to run a script / command
for example when i launch vlc ,
when i close the app i to write to a file some thing like
vlc opened $dd::mm::ss
hi,
not clear, all application is different
if you want, the best is to load application in this script
In general you can use this:
first_command && second_command
&& means it waits till the previous command is finished or closed and then run the second one.
for example when i launch vlc ,
when i close the app i to write to a file some thing like
vlc opened $dd::mm::ss
script example:
#!/usr/bin/env bash
dstart=$(date +"%Y-%m-%d %T")
$@
dstop=$(date +"%Y-%m-%d %T")
echo -e "$1 : ${dstart} : ${dstop}" | systemd-cat -p6 -t "mylog"
#journalctl -t mylog
ps: if use journald, dstop not usefull
for run, change menu loader for: Exec=/home/$USER/bin/myscript.sh vlc --started-from-file %U
or for test in terminal ./myscript "vlc"
Display logs :
journalctl -t mylog # -b0
result:
-- Logs begin at Tue 2020-06-16 10:28:27 CEST, end at Tue 2020-09-08 14:17:36 CEST. --
sept. 08 14:05:35 tower mylog[39237]: vlc : 2020-09-08 14:05:31 : 2020-09-08 14:05:35
sept. 08 14:17:19 tower mylog[39871]: sleep : 2020-09-08 14:17:16 : 2020-09-08 14:17:19
sept. 08 14:17:36 tower mylog[39899]: sleep : 2020-09-08 14:17:35 : 2020-09-08 14:17:36