Add sample created by Cursor

This commit is contained in:
Evgeny
2025-05-03 13:20:09 +08:00
parent 82ce7e6eff
commit 6cdb5a9336

View File

@@ -0,0 +1,33 @@
-- name = "Top Apps"
-- icon = "fa:star"
-- description = "Shows 10 most frequently used applications"
-- type = "widget"
-- foldable = "true"
-- Created in Cursor
-- Original prompt: "Read README and script examples and write a widget script that will display 10 most used applications."
function on_resume()
-- Get list of applications sorted by launch count
local apps = apps:apps("launch_count")
-- Create table for display
local lines = {}
for i = 1, 10 do
if apps[i] then
-- Add number and application name
table.insert(lines, i .. ". " .. apps[i].name)
end
end
-- Display the list
ui:show_lines(lines)
end
-- Handle application click
function on_click(index)
local apps = apps:apps("launch_count")
if apps[index] then
apps:launch(apps[index].pkg)
end
end