Advertisement
Guest User

Dual Battery Conky

a guest
Apr 3rd, 2023
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.23 KB | None | 0 0
  1. 1st file: LUA file
  2. ---------------------
  3. function filetonumber(path)
  4.     local f = io.open(path)
  5.     local nr = f:read()
  6.     f:close()  
  7.     return nr
  8. end
  9.  
  10. function conky_batcapnow()
  11.     local capbat0 = filetonumber("/sys/class/power_supply/BAT0/energy_now")
  12.     local capbat1 = filetonumber("/sys/class/power_supply/BAT1/energy_now")
  13.     local capbat = (capbat0 + capbat1)/1000000
  14.     return capbat
  15. end
  16.  
  17. function conky_batcapfull()
  18.     local capbat0 = filetonumber("/sys/class/power_supply/BAT0/energy_full")
  19.     local capbat1 = filetonumber("/sys/class/power_supply/BAT1/energy_full")
  20.     local capbat = (capbat0 + capbat1)/1000000
  21.     return capbat
  22. end
  23.  
  24. function conky_batcapfulldesign()
  25.     local capbat0 = filetonumber("/sys/class/power_supply/BAT0/energy_full_design")
  26.     local capbat1 = filetonumber("/sys/class/power_supply/BAT1/energy_full_design")
  27.     local capbat = (capbat0 + capbat1)/1000000
  28.     return capbat
  29. end
  30.  
  31. function conky_batpowernow()
  32.     local pwrbat0 = filetonumber("/sys/class/power_supply/BAT0/power_now")
  33.     local pwrbat1 = filetonumber("/sys/class/power_supply/BAT1/power_now")
  34.     local pwrbat = (pwrbat0 + pwrbat1) / 1000000
  35.     return pwrbat
  36. end
  37.  
  38. function conky_batremainingtime()
  39.     local remhrs = (conky_batcapnow() / (conky_batpowernow()+1))
  40.    
  41.     local hours = math.floor(remhrs)
  42.     remhrs = remhrs - hours
  43.     local minutes = math.floor(remhrs*60)
  44.     remhrs = remhrs - (minutes/60)
  45.     local seconds = math.floor(remhrs*60)
  46.    
  47.     return conky_parse(hours .. "h " .. minutes .. "min")
  48. end
  49.  
  50.  
  51. function conky_batpercentage()
  52.     local percent = (conky_batcapnow() / conky_batcapfull())*1000
  53.     return math.floor(percent)/10
  54. end
  55.  
  56. function conky_batteryBO_bar(maxbarlen)
  57.     local e_full_bat0 = filetonumber("/sys/class/power_supply/BAT0/energy_full")
  58.     local e_full_bat1 = filetonumber("/sys/class/power_supply/BAT1/energy_full")
  59.     local len0 = math.floor(maxbarlen * (e_full_bat0/(e_full_bat0+e_full_bat1)))
  60.     local len1 = math.floor(maxbarlen - len0)
  61.     return conky_parse("${battery_bar 15, " .. len0 .. " BAT0} ${battery_bar 15, " .. len1 .. " BAT0}")
  62. end
  63.  
  64. 2nd file:
  65. CONKY FILE:
  66.  
  67. conky.config = {
  68. ---- Informant Conky
  69. ---- Date    : 2023/17/03
  70. ---- Editor  : unimetal
  71. ---- Version : v6.6.6
  72.  
  73. ---- By unimetal
  74.  
  75. --# Add Lua Functions  #####################
  76. lua_load = '~/.conky/MX-Simon/calculations.lua',
  77.  
  78. --# Begin Window Settings  #####################
  79.  
  80.     own_window = true,
  81.     own_window_type = 'normal',
  82. ----original own_window_type is desktop
  83.     own_window_hints = 'undecorated,above,sticky,skip_pager',
  84. own_window_transparent = false,
  85.  
  86. --# ARGB can be used for real transparency
  87. --# NOTE that a composite manager is required for real transparency.
  88. --# This option will not work as desired (in most cases) in conjunction with
  89. --# own_window_type normal
  90. own_window_argb_visual = true,
  91.  
  92. --# When ARGB visuals are enabled, use this to modify the alpha value
  93. --# Use: own_window_type normal
  94. --# Use: own_window_transparent no
  95. --# Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
  96. own_window_argb_value = 150,
  97. own_window_colour = '000000',
  98.  
  99. minimum_width = '250',
  100. minimum_height = '200',
  101.     maximum_width = 250,
  102.  
  103. gap_x = 10,
  104. gap_y = 0,
  105.  
  106. alignment = 'middle_right',
  107.  
  108. --# End Window Settings  ###
  109.  
  110. --# Font Settings  ######################
  111. ---- Use Xft (anti-aliased font and stuff)
  112.     use_xft = true,
  113. -- Requires mono font for spacing reasons
  114. -- xftfont Liberation Mono:bold:size=30
  115.     font = 'Roboto-Light:size=30',
  116.  
  117.  
  118. -- Alpha of Xft font. Must be a value at or between 1 and 0 ###
  119.     xftalpha = 1,
  120. ---- Force UTF8? requires XFT ###
  121.     override_utf8_locale = true,
  122.  
  123.     uppercase = false,
  124. --# End Font Settings  ###
  125.  
  126. --# Colour Settings  ###
  127.     draw_shades = false,--#yes
  128.     default_shade_color = 'black',
  129.  
  130.     draw_outline = false,--# amplifies text if yes
  131.     default_outline_color = 'black',
  132.  
  133. --# Color scheme ##
  134.  
  135. --# fe4515 crimson-orange
  136.     default_color = '#ff0000',
  137.  
  138. --# ffffff white
  139.     color1 = 'ffffff',
  140.  
  141. --#######################
  142.  
  143. --# End Colour Settings  ###
  144.  
  145. --# Borders Section  ##
  146.     draw_borders = false,
  147. ---- Stippled borders?
  148.     stippled_borders = 5,
  149. ---- border margins
  150.     border_inner_margin = 5,
  151.     border_outer_margin = 0,
  152. ---- border width
  153.     border_width = 2,
  154. ---- graph borders
  155.     draw_graph_borders = true,--#no
  156. ----default_graph_size 15 40
  157. --# End Borders Secton  ###
  158.  
  159. --# Miscellaneous Section  ##
  160. ---- Boolean value, if true, Conky will be forked to background when started.
  161.     background = true,
  162.  
  163. ---- Adds spaces around certain objects to stop them from moving other things
  164. ---- around, this only helps if you are using a mono font
  165. ---- Options: right, left or none
  166.     use_spacer = 'none',
  167.  
  168. ---- Default and Minimum size is 256 - needs more for single commands that
  169. ---- "call" a lot of text IE: bash scripts
  170. ----text_buffer_size 6144
  171.  
  172. ---- Subtract (file system) buffers from used memory?
  173.     no_buffers = true,
  174.  
  175. ---- change GiB to G and MiB to M
  176.     short_units = true,
  177.  
  178. ---- Like it says, ot pads the decimals on % values
  179. ---- doesn't seem to work since v1.7.1
  180.     pad_percents = 2,
  181.  
  182. ---- Imlib2 image cache size, in bytes. Default 4MiB Increase this value if you use
  183. ---- $image lots. Set to 0 to disable the image cache.
  184.     imlib_cache_size = 0,
  185.  
  186. ---- Use the Xdbe extension? (eliminates flicker)
  187. ---- It is highly recommended to use own window with this one
  188. ---- so double buffer won't be so big.
  189.     double_buffer = true,
  190.  
  191. ----   Maximum size of user text buffer, i.e. layout below TEXT line in config file
  192. ----  (default is 16384 bytes)
  193. ---- max_user_text 16384
  194.  
  195. ---- Desired output unit of all objects displaying a temperature. Parameters are
  196. ---- either "fahrenheit" or "celsius". The default unit is degree Celsius.
  197. ---- temperature_unit Fahrenheit
  198. --# End Miscellaneous Section  ###
  199.  
  200.     update_interval = 1,
  201.  
  202. minimum_width = 0, minimum_height = 0,
  203.  
  204. -- time template
  205.    template0 = '%H',
  206.  
  207. };
  208.  
  209. -- fluxbox adjustment
  210.  
  211. return_code = os.execute('pidof -q fluxbox')
  212. if _VERSION == 'Lua 5.1' and math.floor(return_code/256) == 0 or
  213.    _VERSION ~= 'Lua 5.1' and return_code then
  214.    conky.config.own_window_transparent = true
  215.    conky.config.own_window_argb_visual = false
  216. end
  217.  
  218.  
  219.  
  220. conky.text = [[
  221. ${font Roboto-Light:Light:size=65}${alignc}${if_match "pmfix${time %p}" == "pmfix"}${time $template0}${else}${time %I}${endif}${color1}:${time %M}${font}${color}
  222. ${font Roboto-Light:Light:size=24}${voffset 12}${alignr}${color1}${time %A},${color} ${time %d}${color0} ${time %B}${font}${voffset 2}
  223. ${color}${font Roboto-Light:Light:size=15}${color}${font size=8}internal${alignr}external
  224. ${color1}${exec awk '{print $0/1000000}' /sys/class/power_supply/BAT0/energy_now} Wh ${alignr}${color1}${exec awk '{print $0/1000000}' /sys/class/power_supply/BAT1/energy_now} Wh
  225. ${color green}${lua conky_batteryBO_bar 245}
  226.  
  227. ${font Roboto-Light:Light:size=15}${color}Remaining: ${alignr}${color1}${lua conky_batremainingtime}
  228. ${font Roboto-Light:Light:size=15}${color}Percentage:${alignr}${color1}${lua conky_batpercentage}%
  229.  
  230. ${color}${font DejaVu Sans Mono:pixelsize=15}CPU        ${color1}${hwmon temp 1}°C${color}  CPU load:  
  231. ${color}${font DejaVu Sans Mono:pixelsize=15}1/4${alignr}${color1}${cpubar cpu0 16,150}
  232. ${color}${font DejaVu Sans Mono:pixelsize=15}2/4${alignr}${color1}${cpubar cpu1 16,150}
  233. ${color}${font DejaVu Sans Mono:pixelsize=15}3/4${alignr}${color1}${cpubar cpu2 16,150}
  234. ${color}${font DejaVu Sans Mono:pixelsize=15}4/4${alignr}${color1}${cpubar cpu3 16,150}
  235.  
  236. ${color}${font DejaVu Sans Mono:pixelsize=13}RAM Usage  :${alignr}${color1}$mem${color} / ${color1}$memmax${color}
  237. ${membar}
  238.  
  239. ${color}${font DejaVu Sans Mono:pixelsize=13}Disk Usage :${alignr}${color1}${fs_used /}${color} / ${color1}${fs_size /}
  240. ${color}${font DejaVu Sans Mono:pixelsize=13}${color}UpTime:${alignr}${color1}$uptime
  241. ${color}${font DejaVu Sans Mono:pixelsize=13}${color}Pbat:${alignr}${color1}${lua conky_batpowernow}Watt
  242. ${color}${font DejaVu Sans Mono:pixelsize=13}${if_existing /proc/net/route wlan0}wlan0: ${alignr}${color green}${addr wlan0}${else}wlan0: ${alignr}${color1}disconnected${endif}
  243. ${color}${font DejaVu Sans Mono:pixelsize=13}${if_existing /proc/net/route eth0}eth0: ${alignr}${color green}${addr wlan0}${else}eth0: ${alignr}${color1}disconnected${endif}
  244. ${color}${font DejaVu Sans Mono:pixelsize=13}${totalup}${totaldown}
  245. ]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement