Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonny Schäfer
tubus
Commits
ae619f40
Commit
ae619f40
authored
Jan 04, 2016
by
Jonny Schäfer
Browse files
add capability to use scripts in ~/.config/tubus/scripts as custom player
parent
317abd88
Changes
2
Hide whitespace changes
Inline
Side-by-side
logic.go
View file @
ae619f40
...
...
@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"sync"
"path/filepath"
)
// maps user input to events
...
...
@@ -385,6 +386,15 @@ func logicSetPlayer(player string) {
func
logicPlay
(
player
string
,
id
int
)
{
video
:=
logicVarVideos
[
id
]
cmd
:=
append
(
strings
.
Split
(
player
,
" "
),
"https://www.youtube.com/watch?v="
+
video
.
url
)
script
:=
filepath
.
Join
(
storeDefaultScripts
,
cmd
[
0
])
exists
,
err
:=
storeFileExists
(
script
)
errorCare
(
err
)
if
exists
{
cmd
[
0
]
=
script
player
=
"$"
+
player
// visual indicator for user script
}
exe
:=
exec
.
Command
(
cmd
[
0
],
cmd
[
1
:
]
...
)
if
err
:=
exe
.
Start
();
err
!=
nil
{
cliStatusError
(
fmt
.
Sprint
(
"playback error: "
,
err
))
...
...
store.go
View file @
ae619f40
...
...
@@ -10,6 +10,7 @@ import (
var
(
storeDefaultPlayer
=
""
// Contains path created by init()
storeDefaultSubscriptions
=
""
// Contains path created by init()
storeDefaultScripts
=
""
// Contains path created by init()
)
// init checks if the configuration directory exist and creates
...
...
@@ -22,10 +23,12 @@ func init() {
home
:=
user
.
HomeDir
conf
:=
filepath
.
Join
(
home
,
".config/tubus"
)
exists
,
err
:=
storeFileExists
(
conf
)
storeDefaultScripts
=
filepath
.
Join
(
conf
,
"scripts"
)
exists
,
err
:=
storeFileExists
(
storeDefaultScripts
)
errorCare
(
err
)
if
!
exists
{
errorCare
(
storeCreateDirectory
(
conf
))
errorCare
(
storeCreateDirectory
(
storeDefaultScripts
))
}
storeDefaultSubscriptions
=
filepath
.
Join
(
conf
,
"subscriptions"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment