Manpage logo

photon-lua - lua plugins documentation and tutorial for photon(1)

NAME  SYNOPSIS  DESCRIPTION  LIBRARY  PHOTON  CARDS  CARD  COLOR CONSTANTS  MEDIA  EVENTS  INPUTS  KEYBINDINGS  LOCAL STORAGE  HTTP LIBRARY  EXAMPLES  SEE ALSO  AUTHORS 

NAME

photon-lua - lua plugins documentation and tutorial for photon(1)

SYNOPSIS

photon can be extended trough lua plugins which are automagically loaded from ~/.config/photon/plugins/*.lua

DESCRIPTION

Lua plugins can subscribe for events that will then call a lua callback function. Generally they then change some state and exit.

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 can be used to subscribe to events, get and set the state of cards and so on.

PHOTON

state()

returns the actual state of the application it can be: photon.Normal, photon.Article, photon.Search

cards

are all the loaded cards. see CARDS

visibleCards

also a CARDS object. Contains only visible cards, that are filtered.

selectedCard

the selected card object. Methods:

posX() X position in the grid

posY() Y position in the grid

card() CARD object

CARDS

Array of CARD object.

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

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.

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

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 a event type and a callback function which takes a event object.

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 <[email protected]>. Up-to-date sources can be found at https://sr.ht/~ghost08/photon and bugs/patches can be submitted by email to ~ghost08/[email protected]


Updated 2026-06-01 - jenkler.se | uex.se