Add keybind to toggle hidden folder visibility
This commit is contained in:
parent
83f3c4f1c8
commit
c5a38c0fd6
8 changed files with 60 additions and 17 deletions
|
@ -1,6 +1,9 @@
|
|||
0.1.4:
|
||||
- Add --fd and --restrict-library options
|
||||
- Add keybind to toggle hidden folder visibility
|
||||
|
||||
0.1.3:
|
||||
- Allow keybindings to be configured
|
||||
- Add --fd and --restrict-library options
|
||||
|
||||
0.1.2:
|
||||
- Allow audio buffer size to be configured
|
||||
|
|
|
@ -14,6 +14,7 @@ configuration options and their defaults.
|
|||
* **Select** Enter
|
||||
* **Pause** Space
|
||||
* **Refresh** R
|
||||
* **Toggle hidden folder visibility** .
|
||||
* **Browse parent folder and focus last** Backspace
|
||||
* **Browse items** J/K, Down/Up and PageDown/PageUp
|
||||
* **Previous track** P
|
||||
|
@ -31,6 +32,8 @@ input:
|
|||
- 'Space'
|
||||
refresh:
|
||||
- 'r'
|
||||
hidden-folders:
|
||||
- '.'
|
||||
browse-parent:
|
||||
- 'Backspace'
|
||||
volume-mute:
|
||||
|
|
13
README.md
13
README.md
|
@ -9,6 +9,12 @@ Audio player
|
|||
|
||||
[![](https://ditty.rocketnine.space/static/screenshot1.png)](https://ditty.rocketnine.space/static/screenshot1.png)
|
||||
|
||||
## Demo
|
||||
|
||||
If you are running Linux with ALSA, you can try ditty without installing:
|
||||
|
||||
```ssh ditty.rocketnine.space -p 20020 2> >(aplay --quiet)```
|
||||
|
||||
## Install
|
||||
|
||||
Choose one of the following methods:
|
||||
|
@ -25,7 +31,12 @@ go get gitlab.com/tslocum/ditty
|
|||
|
||||
## Dependencies
|
||||
|
||||
ditty is powered by [beep](https://github.com/faiface/beep).
|
||||
* [faiface/beep](https://github.com/faiface/beep)
|
||||
* [hajimehoshi/oto](https://github.com/hajimehoshi/oto)
|
||||
* [mewkiz/flac](https://github.com/mewkiz/flac)
|
||||
* [hajimehoshi/go-mp3](https://github.com/hajimehoshi/go-mp3)
|
||||
* [jfreymuth/oggvorbis](https://github.com/jfreymuth/oggvorbis)
|
||||
* [tslocum/cview](https://github.com/tslocum/cview)
|
||||
|
||||
## Documentation
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ builds:
|
|||
env:
|
||||
- CGO_ENABLED=1
|
||||
ldflags:
|
||||
- -s -w -X gitlab.com/tslocum/ditty/version={{.Version}}
|
||||
- -s -w -X main.version={{.Version}}
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
|
|
|
@ -12,6 +12,7 @@ const (
|
|||
actionSelect = "select"
|
||||
actionPause = "pause"
|
||||
actionRefresh = "refresh"
|
||||
actionToggleHidden = "hidden-folders"
|
||||
actionBrowseParent = "browse-parent"
|
||||
actionVolumeMute = "volume-mute"
|
||||
actionVolumeDown = "volume-down"
|
||||
|
@ -29,6 +30,7 @@ var actionHandlers = map[string]func(){
|
|||
actionSelect: listSelect,
|
||||
actionPause: pause,
|
||||
actionRefresh: listRefresh,
|
||||
actionToggleHidden: listToggleHidden,
|
||||
actionBrowseParent: browseParent,
|
||||
actionVolumeMute: toggleMute,
|
||||
actionVolumeDown: decreaseVolume,
|
||||
|
@ -85,6 +87,7 @@ func setDefaultKeyBinds() {
|
|||
actionSelect: {"Enter"},
|
||||
actionPause: {"Space"},
|
||||
actionRefresh: {"r"},
|
||||
actionToggleHidden: {"."},
|
||||
actionBrowseParent: {"Backspace"},
|
||||
actionVolumeMute: {"m"},
|
||||
actionVolumeDown: {"-"},
|
||||
|
|
17
gui_list.go
17
gui_list.go
|
@ -105,3 +105,20 @@ func listRefresh() {
|
|||
mainBufferDirectory = ""
|
||||
browseFolder(d)
|
||||
}
|
||||
|
||||
func listToggleHidden() {
|
||||
showHiddenFolders = !showHiddenFolders
|
||||
|
||||
if showHiddenFolders {
|
||||
statusText = "Hidden folders: show"
|
||||
} else {
|
||||
statusText = "Hidden folders: hide"
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(3 * time.Second)
|
||||
statusText = ""
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
}()
|
||||
|
||||
listRefresh()
|
||||
}
|
||||
|
|
|
@ -59,10 +59,14 @@ func scanFolder(scanPath string) []*libraryEntry {
|
|||
|
||||
var entries []*libraryEntry
|
||||
for _, fileInfo := range files {
|
||||
b := path.Base(fileInfo.Name())
|
||||
if fileInfo.IsDir() {
|
||||
entries = append(entries, &libraryEntry{File: fileInfo, Metadata: &metadata{Title: fileInfo.Name()}})
|
||||
if b != "" && (b[0] != '.' || showHiddenFolders) {
|
||||
entries = append(entries, &libraryEntry{File: fileInfo, Metadata: &metadata{Title: fileInfo.Name()}})
|
||||
}
|
||||
|
||||
continue
|
||||
} else if !supportedFormat(fileInfo.Name()) {
|
||||
} else if !supportedFormat(b) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
26
main.go
26
main.go
|
@ -18,8 +18,7 @@ import (
|
|||
const (
|
||||
volumeBase = 2
|
||||
|
||||
version = "0.0.0"
|
||||
versionInfo = `ditty - Audio player - v` + version + `
|
||||
versionInfo = `ditty - Audio player - v0.0.0
|
||||
https://gitlab.com/tslocum/ditty
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2020 Trevor Slocum <trevor@rocketnine.space>
|
||||
|
@ -27,16 +26,18 @@ Copyright (c) 2020 Trevor Slocum <trevor@rocketnine.space>
|
|||
)
|
||||
|
||||
var (
|
||||
configPath string
|
||||
printVersionInfo bool
|
||||
bufferSize time.Duration
|
||||
debugAddress string
|
||||
cpuProfile string
|
||||
streamFdInt int
|
||||
streamFd *os.File
|
||||
restrictLibrary string
|
||||
configPath string
|
||||
printVersionInfo bool
|
||||
bufferSize time.Duration
|
||||
debugAddress string
|
||||
cpuProfile string
|
||||
streamFdInt int
|
||||
streamFd *os.File
|
||||
restrictLibrary string
|
||||
showHiddenFolders bool
|
||||
|
||||
done = make(chan bool)
|
||||
version = "0.0.0"
|
||||
done = make(chan bool)
|
||||
)
|
||||
|
||||
func exit() {
|
||||
|
@ -52,11 +53,12 @@ func main() {
|
|||
flag.StringVar(&restrictLibrary, "restrict-library", "", "restrict library to path")
|
||||
flag.DurationVar(&bufferSize, "buffer-size", defaultBufferSize, "audio buffer size")
|
||||
flag.StringVar(&debugAddress, "debug-address", "", "address to serve debug info")
|
||||
flag.BoolVar(&showHiddenFolders, "hidden-folders", false, "show hidden folders")
|
||||
flag.StringVar(&cpuProfile, "cpu-profile", "", "path to save CPU profiling")
|
||||
flag.Parse()
|
||||
|
||||
if printVersionInfo {
|
||||
fmt.Print(versionInfo)
|
||||
fmt.Print(strings.Replace(versionInfo, "0.0.0", version, 1))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue