This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Count down command line command

Tags: None
(comma "," separated)
lesjar
Registered Member
Posts
8
Karma
0
OS

Count down command line command

Wed Apr 08, 2020 8:00 pm
Is it possible to set in Kalarm a command for a count down? Say to count down 1
minute from the time the command is executed.
djarvie
KDE Developer
Posts
103
Karma
0
OS

Re: Count down command line command

Thu Apr 09, 2020 9:27 pm
Can you explain what you mean by "count down"? Do you mean showing a visual indication of the time left before the command is to be executed?


KAlarm author
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Fri Apr 10, 2020 4:56 am
djarvie wrote:Can you explain what you mean by "count down"? Do you mean showing a visual indication of the time left before the command is to be executed?

No. I mean a "Time from now" alarm. You set a number of minutes or hours and kalarm counts down this amount of time and then alarms. You can see this option in the middle of this picture:

Image
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Fri Apr 10, 2020 11:28 am
Hi!

You may use the dbus-variants in /kalarm-Path.

Code: Select all
qdbus org.kde.kalarm /kalarm

will show you a list of methods you may use. I assume you need one of org.kde.kalarm.kalarm.scheduleCommand-Methods.
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Sun May 17, 2020 4:21 am
koffeinfriedhof wrote:Hi!

You may use the dbus-variants in /kalarm-Path.

Code: Select all
qdbus org.kde.kalarm /kalarm

will show you a list of methods you may use. I assume you need one of org.kde.kalarm.kalarm.scheduleCommand-Methods.

Hi!

Could you post any example of a working string, please?
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Sun May 17, 2020 6:09 pm
Code: Select all
qdbus org.kde.kalarm /kalarm org.kde.kalarm.kalarm.scheduleCommand "bash -c 'touch /tmp/touched'" "22:15" 0 0 "" 0 0


would create the file /tmp/touched at 10:15pm without any specials. The dbus-Methods are explained in the manual, if you need the daily, monthly, and…so…on-stuff.
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Sun May 17, 2020 7:35 pm
koffeinfriedhof wrote:
Code: Select all
qdbus org.kde.kalarm /kalarm org.kde.kalarm.kalarm.scheduleCommand "bash -c 'touch /tmp/touched'" "22:15" 0 0 "" 0 0


would create the file /tmp/touched at 10:15pm without any specials. The dbus-Methods are explained in the manual, if you need the daily, monthly, and…so…on-stuff.

I see, but I need a solution to count down from now .
For example: to count down 5 minutes and then alarm.
or to count down 30 minutes and then alarm
etc.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Sun May 17, 2020 7:44 pm
You can use the date command.
Code: Select all
date --date='now +30min' +'%H:%M'
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Sun May 17, 2020 8:03 pm
koffeinfriedhof wrote:You can use the date command.
Code: Select all
date --date='now +30min' +'%H:%M'

This command only shows me what time it will be in the specified number of minutes. No alarm happens.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Mon May 18, 2020 12:40 pm
Sure. You have to combine both to a single command, like
Code: Select all
qdbus org.kde.kalarm /kalarm org.kde.kalarm.kalarm.scheduleCommand "bash -c 'touch /tmp/touched'" $(date --date='now +30min' +'%H:%M') 0 0 "" 0 0

(untested). The $() opens a bash subshell returning the result of the command inside the parantheses. But these are questions of scripting or dbus-usage and independent of kalarm :)

More options are described here → https://docs.kde.org/trunk5/en/pim/kalarm/

/edit:
forgot following: Even if the command returns true, it may not work if there is no default calendar defined! You should then look at syslog with
Code: Select all
journalctl -b -t kalarm
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Mon May 18, 2020 7:22 pm
When I run this:
Code: Select all
$ qdbus org.kde.kalarm /kalarm org.kde.kalarm.kalarm.scheduleCommand "bash -c 'touch /tmp/touched'" $(date --date='now +1min' +'%H:%M') 0 0 "" 0 0


I get this:
Code: Select all
false


And nothing else seem to happen.

Then I open the file /var/log/syslog and search the word "kalarm" there. The search returns zero finds.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Tue May 19, 2020 8:38 am
As you are running debian, there could be an old version of plasma running. Could you show the declarations of schedule-functions?
Code: Select all
qdbus org.kde.kalarm /kalarm | grep schedule


With plasma 5.18.5 (framework 5.70.1) it matches 3 possibilities:
Code: Select all
method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, QString recurrence, int subRepeatInterval, int subRepeatCount)
method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, QString endDateTime)
method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, int recurCount)
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Tue May 19, 2020 9:27 am
Is this the info in question?

Code: Select all
$ plasma-desktop -v
Qt: 4.8.6                                                                     
KDE: 4.14.2                                                                   
Оболочка Plasma: 4.11.13     


Code: Select all
$ qdbus org.kde.kalarm /kalarm | grep schedule method bool org.kde.kalarm.kalarm.scheduleAudio(QString audioFile, int volumePercent, QString startDateTime, int lateCancel, uint flags, QString recurrence, int subRepeatInterval, int subRepeatCount) method bool org.kde.kalarm.kalarm.scheduleAudio(QString audioFile, int volumePercent, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, QString endDateTime) method bool org.kde.kalarm.kalarm.scheduleAudio(QString audioFile, int volumePercent, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, int recurCount) method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, QString recurrence, int subRepeatInterval, int subRepeatCount) method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, QString endDateTime) method bool org.kde.kalarm.kalarm.scheduleCommand(QString commandLine, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, int recurCount) method bool org.kde.kalarm.kalarm.scheduleEmail(QString fromID, QString addresses, QString subject, QString message, QString attachments, QString startDateTime, int lateCancel, uint flags, QString recurrence, int subRepeatInterval, int subRepeatCount) method bool org.kde.kalarm.kalarm.scheduleEmail(QString fromID, QString addresses, QString subject, QString message, QString attachments, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, QString endDateTime) method bool org.kde.kalarm.kalarm.scheduleEmail(QString fromID, QString addresses, QString subject, QString message, QString attachments, QString startDateTime, int lateCancel, uint flags, int recurType, int recurInterval, int recurCount) method bool org.kde.kalarm.kalarm.scheduleFile(QString file, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString audioFile, int reminderMins, QString recurrence, int subRepeatInterval, int subRepeatCount) method bool org.kde.kalarm.kalarm.scheduleFile(QString file, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString audioFile, int reminderMins, int recurType, int recurInterval, QString endDateTime) method bool org.kde.kalarm.kalarm.scheduleFile(QString file, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString audioFile, int reminderMins, int recurType, int recurInterval, int recurCount) method bool org.kde.kalarm.kalarm.scheduleMessage(QString message, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString fgColor, QString font, QString audioFile, int reminderMins, QString recurrence, int subRepeatInterval, int subRepeatCount) method bool org.kde.kalarm.kalarm.scheduleMessage(QString message, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString fgColor, QString font, QString audioFile, int reminderMins, int recurType, int recurInterval, QString endDateTime) method bool org.kde.kalarm.kalarm.scheduleMessage(QString message, QString startDateTime, int lateCancel, uint flags, QString bgColor, QString fgColor, QString font, QString audioFile, int reminderMins, int recurType, int recurInterval, int recurCount)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Count down command line command

Tue May 19, 2020 2:04 pm
Wow, okay. That is really old software. 4.14.3 is from Nov, 2014 . I do not use Debian, but do they still support KDE4 or is your system unsupported? Besides your problem here, you should think about upgrading to a newer version of KDE if possible.

Back to topic: To get the error message of kalarm, have a look at dmesg command afair pre-systemd-aera :) Or just use the graphical KSystemLog searching for "kalarm" , which was available for KDE4 too.

The line given matches the arguments of the first occurence of "method bool org.kde.kalarm.kalarm.scheduleCommand", so the issue seems to be something else, like setting a default alarm calendar. bool means the function call returns true or false, so it returns true on success and false on error, but appearently without an error message. As an example, the above command returns true on my system, but nothing happens anyway and my systemlog (systemd → journalctl) contains following line:
May 19 15:54:03 x220arch kalarm[1951]: org.kde.pim.kalarm: AlarmCalendar::addEvent: Error! Cannot create Active alarm (No default calendar is defined) as I have no configuration set up for kalarm and normally do not use it.
Perhaps you'll find an error which points us in the right direction. Is kalarm running in background?
If it is NOT running, you may use the default command line arguments to trigger an event, but KAlarm recommends using dbus-methods to control a running instance.

Are you fixed on using KAlarm? Or do you just need some simple cronjobs? Whats the main goal behind your question?
lesjar
Registered Member
Posts
8
Karma
0
OS

Re: Count down command line command

Tue May 19, 2020 6:16 pm
My Debian version (Jessie) has extremely rare updates now if any still. Indeed, I've tried updating to newer version a long time ago but my system got screwed somehow so I rolled it back. Since then I've just had no time for other experiments and since the system runs OK I've let it be.

I'm not fixed on kalarm. Anything that would count down and alarm while being in background would do allright. I'd like it to be a command attached to a keyboard shortcut.

I'll try kalarm again and reply to the rest of the message a bit later.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]