Advertisement
Zac_McDonald

VOID Battery - Rainmeter

Apr 16th, 2020
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. VOIDBattery.ini
  2. -----------------------------------------------------
  3. [Rainmeter]
  4. Update=2000 ; Every 10 seconds
  5. AccurateText=1
  6. DynamicWindowSize=1
  7. OnUpdateAction=[!CommandMeasure MeasureReadBattery "Run"]
  8.  
  9. [Metadata]
  10. Name=
  11. Author=
  12. Information=
  13. Version=
  14. License=
  15.  
  16. [Variables]
  17.  
  18. [MeasureReadBattery]
  19. Measure=Plugin
  20. Plugin=RunCommand
  21. Parameter=ReadBatteryLevel.exe
  22. State=Hide
  23.  
  24. [MeasureBatteryLevel]
  25. Measure=Script
  26. ScriptFile=read_file.lua
  27. IfCondition=(MeasureBatteryLevel >= 0) && (MeasureBatteryLevel <= 100)
  28. IfTrueAction=[!SetOption MeterBatteryText Text "%1%"]
  29. IfFalseAction=[!SetOption MeterBatteryText Text "N/A"]
  30.  
  31. [MeterBatteryText]
  32. Meter=String
  33. MeasureName=MeasureBatteryLevel
  34. AntiAlias=1
  35. FontColor=165,224,218
  36. FontSize=16
  37. FontFace=Century Gothic
  38. StringAlign=Left
  39. NumOfDecimals=0
  40. AutoScale=1
  41.  
  42.  
  43. read_file.lua
  44. -----------------------------------------------------
  45. function Update()
  46. FilePath = "./battery_level.txt"
  47.  
  48. -- HANDLE RELATIVE PATH OPTIONS.
  49. FilePath = SKIN:MakePathAbsolute(FilePath)
  50.  
  51. -- OPEN FILE.
  52. local File = io.open(FilePath)
  53.  
  54. -- HANDLE ERROR OPENING FILE.
  55. if not File then
  56. print('ReadFile: unable to open file at ' .. FilePath)
  57. return
  58. end
  59.  
  60. -- READ FILE CONTENTS AND CLOSE.
  61. local Contents = File:read('*all')
  62. File:close()
  63.  
  64. return Contents
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement