Allow for optional external viewer args
In order to pass in options like `--new-window` to an external viewer like `firefox`, optional args can now be defined in configuration. See config-example.yaml for an example.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
View RSS feeds from the terminal.
|
View RSS feeds from the terminal.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## configure
|
## configure
|
||||||
|
|
||||||
|
@@ -4,8 +4,9 @@ feeds:
|
|||||||
- https://www.reddit.com/r/golang/.rss
|
- https://www.reddit.com/r/golang/.rss
|
||||||
- https://www.reddit.com/r/linux/.rss
|
- https://www.reddit.com/r/linux/.rss
|
||||||
- https://www.zdnet.com/topic/security/rss.xml
|
- https://www.zdnet.com/topic/security/rss.xml
|
||||||
- https://aws.amazon.com/blogs/security/feed/
|
|
||||||
- https://www.archlinux.org/feeds/news/
|
|
||||||
|
|
||||||
# Optionally define an an external application viewer
|
# Optionally define an application to view the feeds
|
||||||
#externalViewer: firefox
|
#externalViewer: firefox
|
||||||
|
# Optionally define args for the external viewer
|
||||||
|
#externalViewerArgs:
|
||||||
|
#- --new-window
|
||||||
|
@@ -13,8 +13,9 @@ import (
|
|||||||
|
|
||||||
// Configuration stores the global config
|
// Configuration stores the global config
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
Feeds []string `yaml:"feeds"`
|
Feeds []string `yaml:"feeds"`
|
||||||
ExternalViewer string `yaml:"externalViewer,omitempty"`
|
ExternalViewer string `yaml:"externalViewer,omitempty"`
|
||||||
|
ExternalViewerArgs []string `yaml:"externalViewerArgs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultConfiguration can be used if a config is missing
|
// DefaultConfiguration can be used if a config is missing
|
||||||
@@ -22,6 +23,7 @@ var DefaultConfiguration = Configuration{
|
|||||||
Feeds: []string{
|
Feeds: []string{
|
||||||
"https://news.ycombinator.com/rss",
|
"https://news.ycombinator.com/rss",
|
||||||
"https://www.reddit.com/r/golang/.rss",
|
"https://www.reddit.com/r/golang/.rss",
|
||||||
|
"https://www.reddit.com/r/linux/.rss",
|
||||||
"https://www.zdnet.com/topic/security/rss.xml",
|
"https://www.zdnet.com/topic/security/rss.xml",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,6 @@ func TestLoadConfiguration(t *testing.T) {
|
|||||||
"https://www.reddit.com/r/golang/.rss",
|
"https://www.reddit.com/r/golang/.rss",
|
||||||
"https://www.reddit.com/r/linux/.rss",
|
"https://www.reddit.com/r/linux/.rss",
|
||||||
"https://www.zdnet.com/topic/security/rss.xml",
|
"https://www.zdnet.com/topic/security/rss.xml",
|
||||||
"https://aws.amazon.com/blogs/security/feed/",
|
|
||||||
"https://www.archlinux.org/feeds/news/",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
|
8
cui/colours.go
Normal file
8
cui/colours.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package cui
|
||||||
|
|
||||||
|
import "github.com/jroimartin/gocui"
|
||||||
|
|
||||||
|
const (
|
||||||
|
selectionBgColor = gocui.ColorWhite
|
||||||
|
selectionFgColor = gocui.ColorBlack
|
||||||
|
)
|
13
cui/main.go
13
cui/main.go
@@ -63,8 +63,9 @@ func openFeed(g *gocui.Gui, v *gocui.View) error {
|
|||||||
func openItem(g *gocui.Gui, v *gocui.View) error {
|
func openItem(g *gocui.Gui, v *gocui.View) error {
|
||||||
_, cy := v.Cursor()
|
_, cy := v.Cursor()
|
||||||
item := Controller.Rss.Feeds[currentFeed].Items[cy]
|
item := Controller.Rss.Feeds[currentFeed].Items[cy]
|
||||||
viewer := Controller.Config.ExternalViewer
|
err := exec.Command(
|
||||||
err := exec.Command(viewer, item.Link).Start()
|
Controller.Config.ExternalViewer,
|
||||||
|
append(Controller.Config.ExternalViewerArgs, item.Link)...).Start()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -138,8 +139,8 @@ func layout(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
v.Title = "Feeds"
|
v.Title = "Feeds"
|
||||||
v.Highlight = true
|
v.Highlight = true
|
||||||
v.SelBgColor = gocui.ColorGreen
|
v.SelBgColor = selectionBgColor
|
||||||
v.SelFgColor = gocui.ColorBlack
|
v.SelFgColor = selectionFgColor
|
||||||
|
|
||||||
if _, err = setCurrentViewOnTop(g, "feeds"); err != nil {
|
if _, err = setCurrentViewOnTop(g, "feeds"); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -154,8 +155,8 @@ func layout(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
v.Title = "Items"
|
v.Title = "Items"
|
||||||
v.Highlight = true
|
v.Highlight = true
|
||||||
v.SelBgColor = gocui.ColorGreen
|
v.SelBgColor = selectionBgColor
|
||||||
v.SelFgColor = gocui.ColorBlack
|
v.SelFgColor = selectionFgColor
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user