I'm trying to display prayer times in Rainmeter using a Lua script that executes a PowerShell script to fetch prayer time data from a local API. However, despite my efforts, the prayer times are not displaying correctly in Rainmeter.
-- Contains Lua functions to load and extract prayer times from the PowerShell script
function LoadPrayerTimes()
local handle = io.popen("powershell.exe -ExecutionPolicy Bypass -File 'C:/Users/Amine/Documents/Rainmeter/Skins/PrayerSkin/PrayerSkin/PrayerTime/GetPrayerTimes.ps1'")
local output = handle:read("*a")
handle:close()
-- Parse the output and return the prayer times as an array
local prayerTimes = {}
for time in output:gmatch("%S+") do
table.insert(prayerTimes, time)
end
return prayerTimes
end
function Fajr()
local prayerTimes = LoadPrayerTimes()
if prayerTimes then
return prayerTimes[1]
else
return 'N/A'
end
end
-- Other functions for Dohr, Asr, Maghreb, and Isha are similar to Fajr
# Perform an HTTP request to get prayer times
$response = Invoke-RestMethod -Uri "http://127.0.0.1:5000/prayer_times" -Method Get
# Check if the request succeeded
if ($response) {
return $response
} else {
Write-Host "Failed to retrieve prayer times."
}
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Metadata]
Name=Prayer Times
Author=YourName
[MeasureLua]
Measure=Script
ScriptFile=Script.lua
[MeterFajr]
Meter=String
SolidColor=255,255,255
Text=[&MeasureScript:Fajr()]
DynamicVariables=1
-- Other measures for Dohr, Asr, Maghreb, and Isha are similar to Fajr
I've tried using these scripts to display prayer times in Rainmeter, but it's not working as expected. The prayer times are not displaying correctly in Rainmeter, and I'm not sure why. If anyone has any ideas or suggestions on what I could do to solve this issue, I would greatly appreciate your help.
I've revised the configuration to use the WebParser plugin instead of io.popen, as you suggested. Here's the updated code:
Do you think something like this could work?
hackermaaan wrote: ↑April 23rd, 2024, 12:00 am
I'm trying to display prayer times in Rainmeter using a Lua script that executes a PowerShell script to fetch prayer time data from a local API. ...If anyone has any ideas or suggestions on what I could do to solve this issue, I would greatly appreciate your help.
If you want to look at a bit of lua script that calculates the Prayer Times without the need to be online you might like to take a look at
I've noticed that that skin is almost twelve years old now but I think it still works. I have a more recent version which shows the time to the next adhan, a better representation of the moon phase and changes colour according to your wallpaper (ala Chameleon Colors). Let me know if you are interested.
You do not have the required permissions to view the files attached to this post.