diff --git a/samples/top-apps-widget.lua b/samples/top-apps-widget.lua new file mode 100644 index 0000000..f95ca7a --- /dev/null +++ b/samples/top-apps-widget.lua @@ -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 \ No newline at end of file