You are not logged in.
Trying to write conky code to test when AC power cord is unplugged, then kick off a script to display battery status and, turn off when plugged into wall circuit.
Any suggestions?
Thanks.
Last edited by lmart (2022-03-24 22:42:28)
Offline
Trying to write conky code to test when AC power cord is unplugged, then kick off a script to display battery status and, turn off when plugged into wall circuit.
Any suggestions?
Thanks.
Please share what you have already.
8bit
thank you for your reply
do you have conky code to check the ac power cord?
per your request, the following code is for the battery
it does not address the issue of the AC power cord
IF AC POWER CORD UNPLUGGED THEN:
${if_existing /sys/class/power_supply/BAT0}\
${alignr}${battery_bar 8,70 BAT0}\
${endif}\
${if_existing /sys/class/power_supply/BAT1}\
${alignr}${battery_bar 8,70 BAT1}\
${endif}\
END-IF AC POWER CORD UNPLUGGED:
Offline
This might help you. It's the baraction.sh script for spectrum. The battery section takes the status of the AC into account then uses acpi for the output.
You might be able to reverse engineer something for conky, or maybe just use that script and only output the battery information.
You must unlearn what you have learned.
-- yoda
Offline
thanks
will check out your suggestion
to reverse engineer, will need to know what conky commands relate to the AC Power and, right now, unable to find anything that works ... most likely my inability ...
Offline
acpiacadapter may be what you want:
acpiacadapter (adapter)
ACPI ac adapter state. On linux, the adapter option specifies
the subfolder of /sys/class/power_supply containing the state
information (tries "AC" and "ADP1" if there is no argument
given). Non-linux systems ignore it.
acpifan
ACPI fan state.
acpitemp
ACPI temperature in C.
conky has a pretty extensive man page - better than the online document in many ways; open your preferred terminal and "man conky"
You must unlearn what you have learned.
-- yoda
Offline
thanks for your reply
checked the man page before posting and, after many fruitless attempts, started my post
result from terminal session:
$ # AC unplugged
$ cat /sys/class/power_supply/AC/online
0
# AC plugged in
$ cat /sys/class/power_supply/AC/online
1
still trying to figure out exactly how to write the conky code to test this condition
hoped there might be some existing conky code to help me figure out what's what
Offline
resolved:
${if_match ${acpiacadapter} == "off-line"}${color yellow}unplugged${color}${endif}\
Offline
Trying to write conky code to test when AC power cord is unplugged, then kick off a script to display battery status and, turn off when plugged into wall circuit.
In your last post, You wrote "resolved" and posted one line. So, what is the whole code?
When realy solved, please edit your first post, prepend "[Solved]" on the subjectline.
// Regards rbh
Please read before requesting help: "Guide to getting help", "Introduction to the Bunsenlabs Lithium Desktop" and other help topics under "Help & Resources" on the BunsenLabs menu
Offline
thank you
will edit first post and, prepend "[Solved]" on the subject line
per my first post, "Trying to write conky code to test when AC power cord is unplugged", which the code segment posted addresses that issue; ${if_match ${acpiacadapter} == "off-line"}${color yellow}unplugged${color}${endif}\
previously posted battery code replaces ${color yellow}unplugged${color}
actual code from my conf follows:
${if_match ${acpiacadapter} == "off-line"}\
${if_existing /sys/class/power_supply/BAT0}\
${alignr}${battery_bar 8,70 BAT0}
${else}\
${if_existing /sys/class/power_supply/BAT1}\
${alignr}${battery_bar 8,70 BAT1}
${endif}${endif}${endif}\
Offline
Eating my words ...
this code segment does not work
${if_match ${acpiacadapter} == "off-line"}${color yellow}unplugged${color}${endif}\
nor does this code segment
${if_match ${acpiacadapter} == "on-line"}${color yellow}plugged${color}${endif}\
so, back to the basic question: does anyone have conky code to check the status of ac power cord, whether plugged or unplugged?
Offline
^ No, acpiacadapter didn't even work on my laptop.
I was toying with this today since I sometimes like to see the battery info.
Try this in a terminal -
acpi -a
You should get something along the lines of:
Adapter 0: off-line
You can use awk to parse the status. Right now, I'm using:
${execpi 10 acpi -a | awk '/Adapter 0/ {print $3}'}
You may need to actually use a script and not conky variables to do what you want. I bet it's already been done. Ask your question in the main conky thread. That group has done pretty much everything.
Last edited by PackRat (2022-03-24 00:25:17)
You must unlearn what you have learned.
-- yoda
Offline
Thanks,
Coming to the conclusion conky code is unable to accomplish the task of determining the status of the AC (unplugged or not).
Will try your code suggestion. Thanks.
Will try your suggestion of posting on the main board. Thanks.
Offline
^ No, acpiacadapter didn't even work on my laptop.
I was toying with this today since I sometimes like to see the battery info.
Try this in a terminal -
acpi -a
You should get something along the lines of:
Adapter 0: off-line
You can use awk to parse the status. Right now, I'm using:
${execpi 10 acpi -a | awk '/Adapter 0/ {print $3}'}
You may need to actually use a script and not conky variables to do what you want. I bet it's already been done. Ask your question in the main conky thread. That group has done pretty much everything.
PackRat,
Thanks. Your code segment works and, is similar to my code using cat /sys/class/power_supply/AC/online, which returns 0 (off-line) or 1 (on-line).
${if_match ${execpi 10 acpi -a | awk '/Adapter 0/ {print $3}'} == "on-line"}on-line${endif}
Interestingly, ${acpiacadapter} accurately displays the AC status; one-line or off-line. My continuing frustation is that I am unable to test against the results of ${acpiacadapter}.
Will give this post a day or two before marking it solved ...
Offline
PackRat
whoddathunk ... after weeks working on this AC Power (connected, disconnected) issue, success using only conky code ... finally "[Solved]"
Here's the code: ${if_existing /sys/class/power_supply/AC/online 0}${color white}AC is off-line${color}${endif}
When the AC is unplugged, the battery code (not supplied here) kicks off so that no work is lost!
refer to: http://www.ifxgroup.net/conky.htm
${if_existing file_name [string]
if_existing Arguments: file_name [string]
${if_existing ~/results.log "fail"}
${endif}
If the named file exists show everything between "${if_existing}" and the matching "${endif}". The optional second parameter checks for file containing the specified string and prints everything between "${if_existing}" and the matching "${endif}".
Offline