Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Make image viewer user-configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
joshiemoore authored and Bios-Marcel committed Mar 3, 2020
1 parent 6382137 commit 3b764ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
ShowUpdateNotifications: true,
IndicateChannelAccessRestriction: false,
ShowBottomBar: true,
ImageViewer: "feh",
}
)

Expand Down Expand Up @@ -133,6 +134,12 @@ type Config struct {
// ShowBottomBar decides whether an informational line is shown at the
// bottom of cordless or not.
ShowBottomBar bool

// The image viewer to open when the user uses the "view attached images"
// shortcut. This program will be passed a list of 1 or more image links
// as if it were called from the command line, so the selected program
// must be capable of opening image links.
ImageViewer string
}

// Account has a name and a token. The name is just for the users recognition.
Expand Down
2 changes: 1 addition & 1 deletion shortcuts/shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
chatview, tcell.NewEventKey(tcell.KeyRune, 's', tcell.ModNone))
DeleteSelectedMessage = addShortcut("toggle_selected_message_spoilers", "Toggle spoilers in selected message",
chatview, tcell.NewEventKey(tcell.KeyDelete, 0, tcell.ModNone))
ViewSelectedMessageImages = addShortcut("view_selected_message_images", "Open selected message's attached images in feh",
ViewSelectedMessageImages = addShortcut("view_selected_message_images", "View selected message's attached images",
chatview, tcell.NewEventKey(tcell.KeyRune, 'o', tcell.ModNone))

ExpandSelectionToLeft = addShortcut("expand_selection_word_to_left", "Expand selection word to left",
Expand Down
2 changes: 1 addition & 1 deletion ui/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
links = append(links, file.URL)
}
if len(links) > 0 {
cmd := exec.Command("feh", links...)
cmd := exec.Command(config.Current.ImageViewer, links...)
err := cmd.Start()
if err != nil {
window.ShowErrorDialog(err.Error())
Expand Down

0 comments on commit 3b764ac

Please sign in to comment.