photon-lua(7)

πŸ“¦ version 1.0.1, in alpine 3.24

🌸 NAME 🌸

okay bestie, welcome to photon-lua(7) β€” the lua plugins documentation and tutorial for photon(1). That's the whole name, and yes it's iconic. πŸ’–

✨ SYNOPSIS ✨

photon can be extended through lua plugins that are automagically loaded from ~/.config/photon/plugins/*.lua. No cap, that glob is literally the magic plugin door. πŸͺ„

πŸ¦‹ DESCRIPTION πŸ¦‹

Lua plugins can subscribe to events, and then photon calls a lua callback function. Generally they then change some state and exit. Main character plugin behavior, honestly. πŸ’…

Hello world example:

~/.config/photon/plugins/hello_world.lua

photon = require("photon")

photon.events.subscribe(
     photon.events.Init,
     function()
          print("Hello world!")
     end
)

πŸŽ€ LIBRARY πŸŽ€

The photon library can be used to subscribe to events, get and set the state of cards, and so on. It's giving toolkit. ✨

πŸ‘‘ PHOTON πŸ‘‘

  • state() β€” returns the actual state of the application. It can be photon.Normal, photon.Article, or photon.Search.
  • cards β€” all the loaded cards. see CARDS.
  • visibleCards β€” also a CARDS object. Contains only visible cards, that are filtered.
  • selectedCard β€” the selected card object. Its methods are:
    • posX() β€” X position in the grid
    • posY() β€” Y position in the grid
    • card() β€” CARD object

🌈 CARDS 🌈

Array of CARD object. Yes singular "object" in the original, we're keeping the facts exactly. 🫢

  • len() β€” length of the cards array
  • get(index) β€” get the CARD object at index
  • set(index, card) β€” set CARD at index
  • del(index) β€” delete CARD at index
  • add(index, card) β€” add a new CARD at index
  • append(card) β€” append a new CARD
  • create(table) β€” returns a new CARD object created from a lua table

Example of create(table) doing its thing:

newCard = {}
newCard["link"] = "https://example.com/article/2"
newCard["title"] = "article 2"
c = photon.cards.create(newCard)

πŸ’– CARD πŸ’–

Object representing one card in the feed. It's the little feed unit, okay? 🫢

  • link() β€” getter and setter for link
  • image() β€” getter and setter for image
  • title() β€” getter and setter for title
  • content() β€” getter and setter for content
  • description() β€” getter and setter for description
  • published() β€” getter and setter for published
  • feed() β€” gets the FEED object of the CARD
  • getMedia() β€” extracts the MEDIA object
  • runMedia() β€” runs the MEDIA. Opens a default application.
  • openBrowser() β€” opens the CARD link in the default browser/application.
  • openArticle() β€” opens the ARTICLE VIEW for the card.
  • foreground(colorConstant) β€” sets the card foreground color to a COLOR CONSTANT
  • background(colorConstant) β€” sets the card background color to a COLOR CONSTANT

All getters and setters can be used as so:

card = photon.cards.get(1)
--get the link
print("old link: " ... card:link())
--set the link to new value
card:link("https://newlink.com")
print("new link: " ... card:link())

🎨 COLOR CONSTANTS 🎨

The color constants are:

  • ColorBlack
  • ColorMaroon
  • ColorGreen
  • ColorOlive
  • ColorNavy
  • ColorPurple
  • ColorTeal
  • ColorSilver
  • ColorGray
  • ColorRed
  • ColorLime
  • ColorYellow
  • ColorBlue
  • ColorFuchsia
  • ColorAqua
  • ColorWhite

πŸ“ MEDIA πŸ“

  • originalLink β€” original link from the CARD, from which the media link is extracted.
  • links β€” table of extracted media links. Usually with just one link.
  • contentType β€” content type of the media.
  • run() β€” runs the MEDIA. Opens a default application.

πŸ”₯ EVENTS πŸ”₯

subscribe(eventType, function(event)) β€” plugins can subscribe to an event type and a callback function which takes an event object. This is the group-chat subscription model. 😌

Event types:

  • Init β€” when photon has successfully started, and loaded the INPUTS (either from the args or a config file)
  • RunMediaStart β€” when a media link is about to play.
  • RunMediaEnd β€” when a media link is done playing.
  • FeedsDownloaded β€” when all the rss/atom feeds data is downloaded and parsed. CARDS are from now accessible.
  • ArticleOpened β€” when a article was opened
  • LinkOpened β€” when the card link was opened in the default webbrowser

🧚 INPUTS 🧚

photon.inputs β€” an array of links/cmds that photon got from args, or parsed from a config file.

It has the following functions:

  • len() β€” returns the length of inputs
  • get(index) β€” returns a link/cmd at index
  • set(index, string) β€” sets a link at index
  • add(index, string) β€” add a new link at index
  • append(string) β€” the same as inputs:add(inputs:len(), link)

πŸ’€ KEYBINDINGS πŸ’€

TODO

🌸 LOCAL STORAGE 🌸

TODO

⭐ HTTP LIBRARY ⭐

TODO

πŸ¦‹ EXAMPLES πŸ¦‹

TODO

πŸ’œ SEE ALSO πŸ’œ

photon(1)

🫢 AUTHORS 🫢

Maintained by VladimΓ­r Magyar <vladimir@mgyar.me>. Up-to-date sources can be found at https://sr.ht/~ghost08/photon and bugs/patches can be submitted by email to ~ghost08/photon@todo.sr.ht.


mwah πŸ’‹ signing off from photon-lua(7) on 2026-10-14 β€” go make a plugin, bestie! 🌈✨

πŸ“¦ where this page comes from