mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add new urlutil option, and have these be reloadable
Handles #897 and part of #593
This commit is contained in:
parent
25234e03da
commit
68e56eaa10
@ -140,6 +140,8 @@ func (wtfApp *WtfApp) watchForConfigChanges() {
|
|||||||
|
|
||||||
config := cfg.LoadWtfConfigFile(wtfApp.configFilePath)
|
config := cfg.LoadWtfConfigFile(wtfApp.configFilePath)
|
||||||
newApp := NewWtfApp(wtfApp.app, config, wtfApp.configFilePath)
|
newApp := NewWtfApp(wtfApp.app, config, wtfApp.configFilePath)
|
||||||
|
openUrlUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
||||||
|
utils.Init(config.UString("wtf.openFileUtil", "open"), openUrlUtil)
|
||||||
|
|
||||||
newApp.Start()
|
newApp.Start()
|
||||||
case err := <-watch.Error:
|
case err := <-watch.Error:
|
||||||
|
3
main.go
3
main.go
@ -60,7 +60,8 @@ func main() {
|
|||||||
defer profile.Start(profile.MemProfile).Stop()
|
defer profile.Start(profile.MemProfile).Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.Init(config.UString("wtf.openFileUtil", "open"))
|
openUrlUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
|
||||||
|
utils.Init(config.UString("wtf.openFileUtil", "open"), openUrlUtil)
|
||||||
|
|
||||||
setTerm(config)
|
setTerm(config)
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@ package utils
|
|||||||
|
|
||||||
// OpenFileUtil defines the system utility to use to open files
|
// OpenFileUtil defines the system utility to use to open files
|
||||||
var OpenFileUtil = "open"
|
var OpenFileUtil = "open"
|
||||||
|
var OpenUrlUtil = []string{}
|
||||||
|
|
||||||
// Init initializes global settings in the wtf package
|
// Init initializes global settings in the wtf package
|
||||||
func Init(openFileUtil string) {
|
func Init(openFileUtil string, openUrlUtil []string) {
|
||||||
OpenFileUtil = openFileUtil
|
OpenFileUtil = openFileUtil
|
||||||
|
OpenUrlUtil = openUrlUtil
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,12 @@ func Includes(strs []string, val string) bool {
|
|||||||
// OpenFile opens the file defined in `path` via the operating system
|
// OpenFile opens the file defined in `path` via the operating system
|
||||||
func OpenFile(path string) {
|
func OpenFile(path string) {
|
||||||
if (strings.HasPrefix(path, "http://")) || (strings.HasPrefix(path, "https://")) {
|
if (strings.HasPrefix(path, "http://")) || (strings.HasPrefix(path, "https://")) {
|
||||||
|
if len(OpenUrlUtil) > 0 {
|
||||||
|
commands := append(OpenUrlUtil, path)
|
||||||
|
args := commands[1:len(commands)]
|
||||||
|
exec.Command(commands[0], args...).Start()
|
||||||
|
return
|
||||||
|
}
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
exec.Command("xdg-open", path).Start()
|
exec.Command("xdg-open", path).Start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user