JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 18.09.2021, 16:48
amn87 amn87 is offline
Vacuum Cleaner
 
Join Date: Oct 2019
Posts: 18
Default Eventscript: stop downloads when battery % lower than x

I think JDownloader doesn't have any option to stop downloads when the laptop battery is low, right? So I was thinking that if the abovementioned were possible I could make use of a third-party app like Robo Task etc. which has the option to execute batch files.
Thanks.
Reply With Quote
  #2  
Old 18.09.2021, 18:01
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,374
Default

There are limited command line ability with JDownloader, you can find them for memory with --help or /? switches. Please keep in mind that these were originally added back a long time ago, and is quite limited/ I'd even goto say that function set wont change moving forward. There are functional API either clicknload/flashgot api, and the newer and more extensive api which myjdownloader browser extensions/webui runs off.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #3  
Old 19.09.2021, 07:15
amn87 amn87 is offline
Vacuum Cleaner
 
Join Date: Oct 2019
Posts: 18
Default

I took a look into all of the above but couldn't make any progress. Event Scripter in MyJD looked promoising but I don't have the required knowledge. What's the simplest way to stop downloads when the laptop battery falls to say 35%?Right now I can probably with the help of a third-party app hibernate the laptop when battery is low but can that cause the running downloads to become corrupted?
Reply With Quote
  #4  
Old 19.09.2021, 08:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,341
Default

Quote:
Originally Posted by amn87 View Post
Event Scripter in MyJD looked promoising but I don't have the required knowledge.
You can call an external program (powercfg?) in eventscripter to query the current battery level and stop the downloads. If you need help with the script, provide the terminal command which returns the current battery level, or find me in JD Chat.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #5  
Old 19.09.2021, 12:20
amn87 amn87 is offline
Vacuum Cleaner
 
Join Date: Oct 2019
Posts: 18
Default

Quote:
Originally Posted by mgpai View Post
You can call an external program (powercfg?) in eventscripter to query the current battery level and stop the downloads. If you need help with the script, provide the terminal command which returns the current battery level, or find me in JD Chat.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
I found this command to get the battery percentage "WMIC PATH Win32_Battery Get EstimatedChargeRemaining".
Reply With Quote
  #6  
Old 19.09.2021, 13:21
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,341
Default

Quote:
Originally Posted by amn87 View Post
I found this command to get the battery percentage "WMIC PATH Win32_Battery Get EstimatedChargeRemaining".
Solved via IRC:
Code:
/*
    Stop downloads when battery low (Windows OS)
    Trigger : Interval
    Recommended Interval 60000 (1 min)
*/

var target = 20;

if (isDownloadControllerRunning()) {
    try {
        var result = callSync("WMIC", "PATH", "Win32_Battery", "Get", "EstimatedChargeRemaining");
        var remaining = result.match(/EstimatedChargeRemaining  \r\r\n(\d+)                        \r\r\n\r\r\n/)[1];

        remaining < target && stopDownloads();
    } catch (e) {};
}
Reply With Quote
  #7  
Old 20.09.2021, 17:47
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,672
Default

@mgpai: NICE!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #8  
Old 20.09.2021, 17:52
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 59,285
Default

Cool!
__________________
JD Supporter, Plugin Dev. & Community Manager
JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 01:52.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.