mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-27 09:27:37 +01:00
- added configuration directive to use a specific program to open a
link (e.g. open all mp3 files with program mpv).
This commit is contained in:
parent
1b6c94196f
commit
3df833b248
@ -542,3 +542,10 @@ gemini-subscription-window.foreground = cyan
|
|||||||
gemini-subscription-window.input.selected.background = cyan
|
gemini-subscription-window.input.selected.background = cyan
|
||||||
|
|
||||||
gemini-subscription-window.input.selected.foreground = black
|
gemini-subscription-window.input.selected.foreground = black
|
||||||
|
|
||||||
|
# you can instruct the program to open some non gemini link with a
|
||||||
|
# program installed with your system like below
|
||||||
|
# syntax open "REGEXP" with "PROGRAM-NAME"
|
||||||
|
# example:
|
||||||
|
#
|
||||||
|
# open "https?://.+mp3" with "mpv"
|
@ -82,7 +82,10 @@
|
|||||||
(program-events:push-event event))
|
(program-events:push-event event))
|
||||||
(gemini-viewer:request url :enqueue enqueue
|
(gemini-viewer:request url :enqueue enqueue
|
||||||
:use-cached-file-if-exists t))
|
:use-cached-file-if-exists t))
|
||||||
(os-utils:xdg-open url)))
|
(let ((program (swconf:link-regex->program-to-use url)))
|
||||||
|
(if program
|
||||||
|
(os-utils:open-link-with-program program url)
|
||||||
|
(os-utils:xdg-open url)))))
|
||||||
|
|
||||||
(defclass open-links-window ()
|
(defclass open-links-window ()
|
||||||
((links
|
((links
|
||||||
|
@ -118,3 +118,11 @@
|
|||||||
:input stream
|
:input stream
|
||||||
:output t
|
:output t
|
||||||
:error t))))
|
:error t))))
|
||||||
|
|
||||||
|
(defun open-link-with-program (program link)
|
||||||
|
(sb-ext:run-program program
|
||||||
|
(list link)
|
||||||
|
:search t
|
||||||
|
:wait nil
|
||||||
|
:output nil
|
||||||
|
:error :output))
|
||||||
|
@ -323,6 +323,7 @@
|
|||||||
:+ssl-key-name+
|
:+ssl-key-name+
|
||||||
:cpu-number
|
:cpu-number
|
||||||
:xdg-open
|
:xdg-open
|
||||||
|
:open-link-with-program
|
||||||
:getenv
|
:getenv
|
||||||
:default-temp-dir
|
:default-temp-dir
|
||||||
:open-with-editor
|
:open-with-editor
|
||||||
@ -1116,6 +1117,7 @@
|
|||||||
:config-username
|
:config-username
|
||||||
:config-password-echo-character
|
:config-password-echo-character
|
||||||
:config-win-focus-mark
|
:config-win-focus-mark
|
||||||
|
:link-regex->program-to-use
|
||||||
:thread-message-symbol
|
:thread-message-symbol
|
||||||
:thread-message-read-colors
|
:thread-message-read-colors
|
||||||
:thread-message-unread-colors
|
:thread-message-unread-colors
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
;; | COLOR-RE-ASSIGN
|
;; | COLOR-RE-ASSIGN
|
||||||
;; | SERVER-ASSIGN
|
;; | SERVER-ASSIGN
|
||||||
;; | USERNAME-ASSIGN
|
;; | USERNAME-ASSIGN
|
||||||
|
;; | OPEN-LINK-HELPER
|
||||||
;; | GENERIC-ASSIGN)
|
;; | GENERIC-ASSIGN)
|
||||||
;; COMMENT*
|
;; COMMENT*
|
||||||
;; SERVER-ASSIGN := SERVER-KEY BLANKS ASSIGN BLANKS GENERIC-VALUE BLANKS
|
;; SERVER-ASSIGN := SERVER-KEY BLANKS ASSIGN BLANKS GENERIC-VALUE BLANKS
|
||||||
;; USERNAME-ASSIGN := USERNAME-KEY BLANKS ASSIGN BLANKS GENERIC-VALUE BLANKS
|
;; USERNAME-ASSIGN := USERNAME-KEY BLANKS WITH BLANKS GENERIC-VALUE BLANKS
|
||||||
|
;; OPEN-LINK-HELPER := OPEN-LINK-HELPER-KEY BLANKS ASSIGN BLANKS REGEXP PROGRAM-NAME
|
||||||
;; GENERIC-ASSIGN := (and key blanks assign blanks
|
;; GENERIC-ASSIGN := (and key blanks assign blanks
|
||||||
;; (or quoted-string
|
;; (or quoted-string
|
||||||
;; hexcolor
|
;; hexcolor
|
||||||
@ -40,11 +42,15 @@
|
|||||||
;; KEY := FIELD (FIELD-SEPARATOR KEY)*
|
;; KEY := FIELD (FIELD-SEPARATOR KEY)*
|
||||||
;; BLANKS := (BLANK)*
|
;; BLANKS := (BLANK)*
|
||||||
;; FILEPATH := QUOTED-STRING
|
;; FILEPATH := QUOTED-STRING
|
||||||
|
;; PROGRAM-NAME := QUOTED-STRING
|
||||||
;; USE := "use"
|
;; USE := "use"
|
||||||
;; SERVER-KEY := "server"
|
;; SERVER-KEY := "server"
|
||||||
;; USERNAME-KEY := "username"
|
;; USERNAME-KEY := "username"
|
||||||
;; COLOR-RE-KEY := "color-regexp"
|
;; COLOR-RE-KEY := "color-regexp"
|
||||||
;; IGNORE-USER-RE-KEY := "ignore-user-regexp"
|
;; IGNORE-USER-RE-KEY := "ignore-user-regexp"
|
||||||
|
;; OPEN := "open"
|
||||||
|
;; OPEN-LINK-HELPER-KEY := OPEN
|
||||||
|
;; WITH-KEY := "with"
|
||||||
;; REGEXP := QUOTED-STRING
|
;; REGEXP := QUOTED-STRING
|
||||||
;; QUOTED-STRING := #\" (not #\") #\"
|
;; QUOTED-STRING := #\" (not #\") #\"
|
||||||
;; FIELD := ( (or ESCAPED-CHARACTER
|
;; FIELD := ( (or ESCAPED-CHARACTER
|
||||||
@ -257,6 +263,14 @@
|
|||||||
(defrule username-key "username"
|
(defrule username-key "username"
|
||||||
(:constant :username))
|
(:constant :username))
|
||||||
|
|
||||||
|
(defrule open "open"
|
||||||
|
(:constant :open))
|
||||||
|
|
||||||
|
(defrule open-link-helper-key open)
|
||||||
|
|
||||||
|
(defrule with "with"
|
||||||
|
(:constant :with))
|
||||||
|
|
||||||
(defrule server-assign
|
(defrule server-assign
|
||||||
(and server-key blanks assign blanks generic-value blanks)
|
(and server-key blanks assign blanks generic-value blanks)
|
||||||
(:function remove-if-null))
|
(:function remove-if-null))
|
||||||
@ -265,6 +279,43 @@
|
|||||||
(and username-key blanks assign blanks generic-value blanks)
|
(and username-key blanks assign blanks generic-value blanks)
|
||||||
(:function remove-if-null))
|
(:function remove-if-null))
|
||||||
|
|
||||||
|
(defclass open-link-helper ()
|
||||||
|
((re
|
||||||
|
:initform nil
|
||||||
|
:initarg :re
|
||||||
|
:accessor re)
|
||||||
|
(program-name
|
||||||
|
:initform nil
|
||||||
|
:initarg :program-name
|
||||||
|
:accessor program-name))
|
||||||
|
(:documentation "When a gemini link matches `re' try to open it with 'program-name'"))
|
||||||
|
|
||||||
|
(defmethod print-object ((object open-link-helper) stream)
|
||||||
|
(print-unreadable-object (object stream :type t :identity nil)
|
||||||
|
(with-accessors ((re re)
|
||||||
|
(program-name program-name)) object
|
||||||
|
(format stream "re: ~s program: ~s" re program-name))))
|
||||||
|
|
||||||
|
(defun make-open-link-helper (re program-name)
|
||||||
|
(assert (stringp program-name))
|
||||||
|
(assert (stringp re))
|
||||||
|
(make-instance 'open-link-helper
|
||||||
|
:re re
|
||||||
|
:program-name program-name))
|
||||||
|
|
||||||
|
(defrule open-link-helper
|
||||||
|
(and open-link-helper-key
|
||||||
|
blanks
|
||||||
|
regexp ; 2
|
||||||
|
blanks
|
||||||
|
with
|
||||||
|
blanks
|
||||||
|
regexp ; 6
|
||||||
|
blanks)
|
||||||
|
(:function (lambda (args)
|
||||||
|
(list :open-link-helper
|
||||||
|
(make-open-link-helper (elt args 2) (elt args 6))))))
|
||||||
|
|
||||||
(defrule filepath quoted-string)
|
(defrule filepath quoted-string)
|
||||||
|
|
||||||
(defparameter *already-included-files* ())
|
(defparameter *already-included-files* ())
|
||||||
@ -286,6 +337,7 @@
|
|||||||
ignore-user-re-assign
|
ignore-user-re-assign
|
||||||
server-assign
|
server-assign
|
||||||
username-assign
|
username-assign
|
||||||
|
open-link-helper
|
||||||
generic-assign)
|
generic-assign)
|
||||||
(* comment))
|
(* comment))
|
||||||
(:function second))
|
(:function second))
|
||||||
@ -356,6 +408,7 @@
|
|||||||
mark
|
mark
|
||||||
vote-vertical-bar
|
vote-vertical-bar
|
||||||
crypted
|
crypted
|
||||||
|
open-link-helper
|
||||||
histogram
|
histogram
|
||||||
error-dialog
|
error-dialog
|
||||||
info-dialog
|
info-dialog
|
||||||
@ -437,7 +490,8 @@
|
|||||||
(value (second entry)))
|
(value (second entry)))
|
||||||
(cond
|
(cond
|
||||||
((or (eq +key-color-re+ key)
|
((or (eq +key-color-re+ key)
|
||||||
(eq +key-ignore-user-re+ key))
|
(eq +key-ignore-user-re+ key)
|
||||||
|
(eq +key-open-link-helper+ key))
|
||||||
(setf (access:accesses *software-configuration* key)
|
(setf (access:accesses *software-configuration* key)
|
||||||
(append (access:accesses *software-configuration* key)
|
(append (access:accesses *software-configuration* key)
|
||||||
(list value))))
|
(list value))))
|
||||||
@ -712,6 +766,14 @@
|
|||||||
(gen-simple-access (password-echo-character)
|
(gen-simple-access (password-echo-character)
|
||||||
+key-password-echo-character+)
|
+key-password-echo-character+)
|
||||||
|
|
||||||
|
(gen-simple-access (all-link-open-program) +key-open-link-helper+)
|
||||||
|
|
||||||
|
(defun link-regex->program-to-use (link)
|
||||||
|
(let ((found (find-if (lambda (a)
|
||||||
|
(cl-ppcre:scan (re a) link))
|
||||||
|
(config-all-link-open-program))))
|
||||||
|
(program-name found)))
|
||||||
|
|
||||||
(defun config-win-focus-mark ()
|
(defun config-win-focus-mark ()
|
||||||
(values (access:accesses *software-configuration*
|
(values (access:accesses *software-configuration*
|
||||||
+key-window+
|
+key-window+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user