photon-lua - lua plugins documentation and tutorial for photon(1)
photon can be extended trough lua plugins which are automagically loaded from ~/.config/photon/plugins/*.lua
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 |
)
The photon can be used to subscribe to events, get and set the state of cards and so on.
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 |
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)
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())
ColorBlack, ColorMaroon, ColorGreen, ColorOlive, ColorNavy, ColorPurple,
ColorTeal, ColorSilver, ColorGray, ColorRed, ColorLime, ColorYellow, ColorBlue,
ColorFuchsia, ColorAqua, ColorWhite
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.
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
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)
TODO
TODO
TODO
TODO
photon(1)
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]