Welcome!
Important information
-- Required MX 15/16 Repository Changes
-- Information on torrent hosting changes
-- Information on MX15/16 GPG Keys
-- Spectre and Meltdown vulnerabilities

News
-- Introducing our new Website
-- MX Linux on social media: here

Current releases
-- MX-18.3 Point Release release info here
-- Migration Information to MX-18 here
-- antiX-17.4.1 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

want to detect battery for conky

Help for Current Versions of MX
User avatar
Jerry3904
Forum Veteran
Forum Veteran
Posts: 24619
Joined: Wed Jul 19, 2006 6:13 am

want to detect battery for conky

#1

Post by Jerry3904 » Fri Jan 11, 2019 12:10 pm

I want to suppress the battery info on a conky if none is present (like on my desktop). I have found out that a laptop will show BAT0 or BAT1 in /sys/class/power_supply/. So how can create an if condition based on the presence of the string "BAT"?
Production: 4.15.0-1-amd64, MX-17.1, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB, SSD 120 GB, Data 1TB
Testing: AAO 722: 4.15.0-1-386. MX-17.1, AMD C-60 APU, 4 GB
Personal: XPS 13, 4.18.0-19.3-liquorix, 4 GB

User avatar
gimcrack
Forum Novice
Forum  Novice
Posts: 81
Joined: Fri Dec 02, 2011 6:17 pm

Re: want to detect battery for conky

#2

Post by gimcrack » Fri Jan 11, 2019 12:56 pm

In the conky script.

This might help. I drop some link in reddit.com. The last post put their successful battery conky codes.

https://www.reddit.com/r/linux4noobs/co ... ery_level/

User avatar
Jerry3904
Forum Veteran
Forum Veteran
Posts: 24619
Joined: Wed Jul 19, 2006 6:13 am

Re: want to detect battery for conky

#3

Post by Jerry3904 » Fri Jan 11, 2019 3:28 pm

Thanks, but that part I have set correctly. My question is: how can I frame the battery section of the conky script with a condition that means only show if satisfied (i.e., "BAT" is present in that file).
Production: 4.15.0-1-amd64, MX-17.1, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB, SSD 120 GB, Data 1TB
Testing: AAO 722: 4.15.0-1-386. MX-17.1, AMD C-60 APU, 4 GB
Personal: XPS 13, 4.18.0-19.3-liquorix, 4 GB

User avatar
gimcrack
Forum Novice
Forum  Novice
Posts: 81
Joined: Fri Dec 02, 2011 6:17 pm

Re: want to detect battery for conky

#4

Post by gimcrack » Fri Jan 11, 2019 4:26 pm

Jerry3904 wrote:
Fri Jan 11, 2019 3:28 pm
Thanks, but that part I have set correctly. My question is: how can I frame the battery section of the conky script with a condition that means only show if satisfied (i.e., "BAT" is present in that file).
https://bbs.archlinux.org/viewtopic.php?id=133716
https://sourceforge.net/p/conky/bugs/320/

Something like this I guess;

$acpiacadapter
${battery BAT1} ${battery_time BAT1}

User avatar
KoO
Forum Regular
Forum Regular
Posts: 504
Joined: Fri Feb 10, 2017 1:21 am

Re: want to detect battery for conky

#5

Post by KoO » Fri Jan 11, 2019 7:33 pm

Try this you may need to change the 0 to 1

${if_match "$battery_percent" != "0"}Batt: $battery_percent% ${endif}

He only want to see the battery in conky if their is one present.
Main : Debian buster antiX17 (i3) , Liquorix 5.1.0-7.2 , Intel Xeon E3-1241 v3 , 16gb , GTX970 . :linuxlove:
Lenovo T430 : antiX17 (i3) , 4.20.12 , i5 , 8gb .
Lenovo X220 : antiX17 (i3) , 4.19.170 , i5 , 8gb . BiosMod 1.46

User avatar
asqwerth
Forum Veteran
Forum Veteran
Posts: 4579
Joined: Sun May 27, 2007 5:37 am

Re: want to detect battery for conky

#6

Post by asqwerth » Fri Jan 11, 2019 11:00 pm

You might wish to examine the configuration file for mx-antix conky which is provided by default in mx17 /18.
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
KoO
Forum Regular
Forum Regular
Posts: 504
Joined: Fri Feb 10, 2017 1:21 am

Re: want to detect battery for conky

#7

Post by KoO » Sat Jan 12, 2019 5:17 am

I found a battery bar on line.Above 45% yellow , 45-25% blue , below 10% red

Code: Select all

${alignc}${if_match battery_percent BAT0}%
${if_match ${battery_percent BAT0} >= 45}${color FFFF00}${battery_bar 6 BAT0}${else} ${if_match ${battery_percent BAT0} >= 25}${color 2600ff}${battery_bar 6 BAT0}${else}${color B22222}${if_match ${battery_percent} =< 10} ${battery_bar 6 BAT0}${endif}
Image
Last edited by KoO on Sun Jan 13, 2019 9:02 am, edited 1 time in total.
Main : Debian buster antiX17 (i3) , Liquorix 5.1.0-7.2 , Intel Xeon E3-1241 v3 , 16gb , GTX970 . :linuxlove:
Lenovo T430 : antiX17 (i3) , 4.20.12 , i5 , 8gb .
Lenovo X220 : antiX17 (i3) , 4.19.170 , i5 , 8gb . BiosMod 1.46

User avatar
Jerry3904
Forum Veteran
Forum Veteran
Posts: 24619
Joined: Wed Jul 19, 2006 6:13 am

Re: want to detect battery for conky

#8

Post by Jerry3904 » Sun Jan 13, 2019 8:17 am

Thanks, but I want it to disappear when no battery is operating. I have found a solution that seems to work on my laptop, testing it now:

Code: Select all

${if match /sys/class?power_supply "BAT"}...${endif}
Production: 4.15.0-1-amd64, MX-17.1, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB, SSD 120 GB, Data 1TB
Testing: AAO 722: 4.15.0-1-386. MX-17.1, AMD C-60 APU, 4 GB
Personal: XPS 13, 4.18.0-19.3-liquorix, 4 GB

User avatar
KoO
Forum Regular
Forum Regular
Posts: 504
Joined: Fri Feb 10, 2017 1:21 am

Re: want to detect battery for conky

#9

Post by KoO » Sun Jan 13, 2019 8:23 am

Code: Select all

${alignc}${if match /sys/class?power_supply "BAT"}${battery_percent BAT0}%
${if_match ${battery_percent BAT0} >= 45}${color FFFF00}${battery_bar 6 BAT0}${else} ${if_match ${battery_percent BAT0} >= 25}${color 2600ff}${battery_bar 6 BAT0}${else}${color B22222}${if_match ${battery_percent} =< 10} ${battery_bar 6 BAT0}${endif}
You are the man Thanks
Main : Debian buster antiX17 (i3) , Liquorix 5.1.0-7.2 , Intel Xeon E3-1241 v3 , 16gb , GTX970 . :linuxlove:
Lenovo T430 : antiX17 (i3) , 4.20.12 , i5 , 8gb .
Lenovo X220 : antiX17 (i3) , 4.19.170 , i5 , 8gb . BiosMod 1.46

User avatar
Jerry3904
Forum Veteran
Forum Veteran
Posts: 24619
Joined: Wed Jul 19, 2006 6:13 am

Re: want to detect battery for conky

#10

Post by Jerry3904 » Sun Jan 13, 2019 8:33 am

Thanks for testing--don't know why it bugged me so much that I just had to find a solution.
Production: 4.15.0-1-amd64, MX-17.1, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB, SSD 120 GB, Data 1TB
Testing: AAO 722: 4.15.0-1-386. MX-17.1, AMD C-60 APU, 4 GB
Personal: XPS 13, 4.18.0-19.3-liquorix, 4 GB

Post Reply

Return to “MX Help”