photon-lua(7)
πΈ 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 bephoton.Normal,photon.Article, orphoton.Search.cardsβ all the loaded cards. see CARDS.visibleCardsβ also aCARDSobject. Contains only visible cards, that are filtered.selectedCardβ the selected card object. Its methods are:posX()β X position in the gridposY()β Y position in the gridcard()βCARDobject
π CARDS π
Array of CARD object. Yes singular "object" in the original, we're keeping the facts exactly. π«Ά
len()β length of the cards arrayget(index)β get theCARDobject atindexset(index, card)β setCARDatindexdel(index)β deleteCARDatindexadd(index, card)β add a newCARDatindexappend(card)β append a newCARDcreate(table)β returns a newCARDobject 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 forlinkimage()β getter and setter forimagetitle()β getter and setter fortitlecontent()β getter and setter forcontentdescription()β getter and setter fordescriptionpublished()β getter and setter forpublishedfeed()β gets theFEEDobject of theCARDgetMedia()β extracts theMEDIAobjectrunMedia()β runs theMEDIA. Opens a default application.openBrowser()β opens theCARDlink in the default browser/application.openArticle()β opens theARTICLE VIEWfor the card.foreground(colorConstant)β sets the card foreground color to aCOLOR CONSTANTbackground(colorConstant)β sets the card background color to aCOLOR 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:
ColorBlackColorMaroonColorGreenColorOliveColorNavyColorPurpleColorTealColorSilverColorGrayColorRedColorLimeColorYellowColorBlueColorFuchsiaColorAquaColorWhite
π MEDIA π
originalLinkβ original link from theCARD, 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 theMEDIA. 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 theINPUTS(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.CARDSare from now accessible.ArticleOpenedβ when a article was openedLinkOpenedβ 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 inputsget(index)β returns a link/cmd atindexset(index, string)β sets a link atindexadd(index, string)β add a new link atindexappend(string)β the same asinputs:add(inputs:len(), link)
π KEYBINDINGS π
TODO
πΈ LOCAL STORAGE πΈ
TODO
β HTTP LIBRARY β
TODO
π¦ EXAMPLES π¦
TODO
π SEE ALSO π
π«Ά 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
- alpine 3.24: photon-doc 1.0.1-r27 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms