Skip to content

Improve default options and behaviour. #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1391211
root: automatically set `C:/` and `/` based on OS
CogentRedTester Mar 8, 2025
15ad19f
rename `modules/parsers` to `modules/addons`
CogentRedTester Mar 8, 2025
66a428d
winroot: make an internal addon
CogentRedTester Mar 8, 2025
5b0f3ea
winroot: only activate on windows
CogentRedTester Mar 8, 2025
ede554b
winroot: add script-opt to disable the behaviour
CogentRedTester Mar 8, 2025
a75002d
update various script-opts to new defaults
CogentRedTester Mar 8, 2025
931b8f8
find: make an internal addon
CogentRedTester Mar 8, 2025
31eacd3
find: properly initialise variable
CogentRedTester Mar 8, 2025
45ab46d
update headers for internal addons
CogentRedTester Mar 8, 2025
3fb9fb2
ls: make an internal addon
CogentRedTester Mar 8, 2025
0c804e9
ls: update to not run on windows and conform to latest best practices
CogentRedTester Mar 8, 2025
0a57430
windir: make an internal addon
CogentRedTester Mar 9, 2025
e7ee666
windir: manually parse utf16
CogentRedTester Mar 9, 2025
595a6a4
windir: only run on windows
CogentRedTester Mar 9, 2025
d2d33b4
windir: improve code to follow new best practices
CogentRedTester Mar 9, 2025
142327c
Apply suggestions from code review
CogentRedTester Mar 14, 2025
a1392c8
add script-opts to disable internal ls and windir addons
CogentRedTester Mar 16, 2025
3a9735f
Merge branch 'master' into new-defaults
CogentRedTester Mar 16, 2025
297a081
addons: enable by default
CogentRedTester Mar 16, 2025
7816c2b
custom-keybinds: enable by default
CogentRedTester Mar 16, 2025
94772b7
README: update installation instructions
CogentRedTester Mar 16, 2025
e941e44
keybinds: fix bug in Ctrl+r keybind
CogentRedTester Mar 16, 2025
10cdfc1
custom-keybinds: example file more generally useful keybinds
CogentRedTester Mar 16, 2025
9b7a8f6
Merge branch 'master' into new-defaults
CogentRedTester Mar 16, 2025
30682a2
last-open-directory: make an internal addon
CogentRedTester Mar 21, 2025
0107731
last-opened-directory: add script-opts to control addon
CogentRedTester Mar 21, 2025
e53b7fe
home-label: add script-opt to disable
CogentRedTester Mar 21, 2025
4613e9a
cache: fix incorrect minimum api version
CogentRedTester Mar 21, 2025
940256e
addons.md: fix hrefs to example addons and priority table
CogentRedTester Mar 21, 2025
d4719a9
ass: allow substituting `%^` for the header ass style
CogentRedTester Mar 21, 2025
36398cc
style: update default headers and wrappers
CogentRedTester Mar 21, 2025
648227f
Merge branch 'master' into new-defaults
CogentRedTester Mar 21, 2025
f48fa80
ass: represent newlines with a coloured symbol
CogentRedTester Mar 21, 2025
8beeca8
file_browser.conf: reorder opts into categories
CogentRedTester Mar 21, 2025
1a2418f
custom-keybinds: allow overriding file
CogentRedTester Mar 21, 2025
93bd0ad
styling: change new wrappers to be same font size as items
CogentRedTester Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,31 @@ You can then pull to receive updates.
Alternatively, you can download the zip and extract the contents to `~~/scripts/file-browser`.
`~~/` is the mpv config directory which is typically `~/.config/mpv/` on linux and `%APPDATA%/mpv/` on windows.

Create a `file_browser.conf` file in the `~~/script-opts/` directory and customise the [`root` option](#root-directory) for your
system. The [`docs/file_browser.conf`](docs/file_browser.conf) file contains the full list of options and their defaults.
### Configuration

Create a `file_browser.conf` file in the `~~/script-opts/` directory to configure the script.
See [docs/file_browser.conf](docs/file_browser.conf) for the full list of options and their default values.
The [`root` option](#root-directory) may be worth tweaking for your system.

### Addons

To use [addons](addons/README.md) place addon files in the `~~/script-modules/file-browser-addons/` directory.

### Custom Keybinds
To setup [custom keybinds](docs/custom-keybinds.md) create a `~~/script-opts/file-browser-keybinds.json` file.
Do **not** copy the `file-browser-keybinds.json` file
stored in this repository, that file is a collection of random examples, many of which are for completely different
operating systems. Use them and the [docs](docs/custom-keybinds.md) to create your own collection of keybinds.

### File Structure

<details>
<summary>Expected directory tree:</summary>
<summary>Expected directory tree (basic):</summary>

```
~~/
├── script-opts
│   └── file-browser.conf
│   └── file_browser.conf
└── scripts
   └── file-browser
      ├── addons/
Expand All @@ -47,21 +62,8 @@ system. The [`docs/file_browser.conf`](docs/file_browser.conf) file contains the
```
</details>

### Advanced

To setup [custom keybinds](docs/custom-keybinds.md) enable the `custom_keybinds` option in `file_browser.conf` and
create a `~~/script-opts/file-browser-keybinds.json` file. Do **not** copy the `file-browser-keybinds.json` file
stored in this repository, that file is a collection of random examples, many of which are for completely different
operating systems. Use them and the [docs](docs/custom-keybinds.md) to create your own collection of keybinds.

To setup [addons](addons/README.md) enable the `addons` option in `file_browser.conf` and place the addon files
in the `~~/script-modules/file-browser-addons/` directory.

If you are not going to enable custom keybinds or addons then there is no reason to
create `file-browser-keybinds.json` or `script-modules/file-browser-addons/`.

<details>
<summary>Expected directory tree:</summary>
<summary>Expected directory tree (full):</summary>

```
~~/
Expand Down Expand Up @@ -120,6 +122,10 @@ The following dynamic keybinds are only set while the browser is open:
| s | select_mode | toggles multiselect mode |
| S | select_item | toggles selection for the current item |
| Ctrl+a | select_all | select all items in the current directory |
| Ctrl+f | find/find | Opens a text input to search the contents of the folder - requires [mpv-user-input](#mpv-user-input) when mpv < v0.38|
| Ctrl+F | find/find_advanced| Allows using [Lua Patterns](https://www.lua.org/manual/5.1/manual.html#5.4.1) in the search input|
| n | find/next | Jumps to the next matching entry for the latest search term |
| N | find/prev | Jumps to the previous matching entry for the latest search term |

When attempting to play or append a subtitle file the script will instead load the subtitle track into the existing video.

Expand All @@ -130,11 +136,9 @@ By default the playlist will only be autoloaded if `Alt+ENTER` is used on a sing

To accomodate for both windows and linux this script has its own virtual root directory where drives and file folders can be manually added. The root directory can only contain folders.

The root directory is set using the `root` option, which is a comma separated list of directories. Entries are sent through mpv's `expand-path` command. By default the only root value is the user's home folder:

`root=~/`

It is highly recommended that this be customised for the computer being used; [file_browser.conf](file_browser.conf) contains commented out suggestions for generic linux and windows systems. For example, my windows root looks like:
The root directory is set using the `root` option, which is a comma separated list of directories. Entries are sent through mpv's `expand-path` command. By default `~/` and `C:/` are set on Windows
and `~/` and `/` are set on non-Windows systems.
Extra locations can be added manually, for example, my Windows root looks like:

`root=~/,C:/,D:/,E:/,Z:/`

Expand Down Expand Up @@ -189,11 +193,6 @@ The `response-string` refers to an arbitrary script-message that the tables shou

This script-message allows other scripts to utilise file-browser's directory parsing capabilities, as well as those of the file-browser addons.

## Configuration

See [file_browser.conf](docs/file_browser.conf) for the full list of options and their default values.
The file is placed in the `~~/script-opts/` folder.

## Conditional Auto-Profiles

file-browser provides a property that can be used with [conditional auto-profiles](https://mpv.io/manual/master/#conditional-auto-profiles)
Expand Down
110 changes: 0 additions & 110 deletions addons/windir.lua

This file was deleted.

27 changes: 17 additions & 10 deletions docs/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ Below is a table of suggested priority ranges:

| Range | Suggested Use | Example parsers |
|---------|------------------------------------------------------------------------------------------------|------------------------------------------------|
| 0-20 | parsers that purely modify the results of other parsers | [m3u-fixer](m3u-browser.lua) |
| 21-40 | virtual filesystems which need to link to the results of other parsers | [favourites](favourites.lua) |
| 0 | priority of the internal cache addon that caches the results of other parsers | [cache](../modules/addons/cache.lua) |
| 1-20 | parsers that purely modify the results of other parsers | [url-decode](../addons/url-decode.lua) |
| 21-40 | virtual filesystems which need to link to the results of other parsers | [favourites](../addons/favourites.lua) |
| 41-50 | to support specific sites or systems which can be inferred from the path | |
| 51-80 | limitted support for specific protocols which requires complex parsing to verify compatability | [apache](apache-browser.lua) |
| 81-90 | parsers that only need to modify the results of full parsers | [home-label](home-label.lua) |
| 91-100 | use for parsers which fully support a non-native protocol with absolutely no overlap | [ftp](ftp-browser.lua), [m3u](m3u-browser.lua) |
| 101-109 | replacements for the native file parser or fallbacks for the full parsers | [powershell](powershell.lua) |
| 110 | priority of the native file parser - don't use | |
| 51-70 | | |
| 71-80 | limitted support for specific protocols which requires complex parsing to verify compatability | [apache](../addons/apache-browser.lua) |
| 81-90 | parsers that only need to modify the results of full parsers | [home-label](../modules/addons/home-label.lua) |
| 91-100 | use for parsers which fully support a non-native protocol with absolutely no overlap | [ftp](../addons/ftp-browser.lua) |
| 101-109 | replacements for the native file parser or fallbacks for the full parsers | [ls](../modules/addons/ls.lua) |
| 110 | priority of the native file parser - don't use | [file](../modules/addons/file.lua) |
| 111+ | fallbacks for native parser - potentially alternatives to the default root | |

## Keybinds
Expand Down Expand Up @@ -994,9 +996,14 @@ If the input is not a number return false, if the input is out of bounds move it

## Examples

For standard addons that add support for non-native filesystems, but otherwise don't do anything fancy, see [ftp-browser](ftp-browser.lua) and [apache-browser](apache-browser.lua).
The internal [file](../modules/addons/file.lua), [ls](../modules/addons/ls.lua), and [windir](../modules/addons/windir.lua) addons provide
support for browsing the native filesystem.

For more simple addons that make a few small modifications to how other parsers are displayed, see [home-label](home-label.lua).
For standard addons that add support for non-native filesystems, but otherwise don't do anything fancy, see [ftp-browser](../addons/ftp-browser.lua) and [apache-browser](../addons/apache-browser.lua).

For more simple addons that make a few small modifications to how other parsers are displayed, see [home-label](../modules/addons/home-label.lua).

For more complex addons that maintain their own virtual directory structure, see
[favourites](favourites.lua).
[favourites](../addons/favourites.lua).


83 changes: 8 additions & 75 deletions docs/file-browser-keybinds.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,10 @@
[
{
"key": "KP1",
"command": ["print-text", "file: %f"],
"multiselect": true
},
{
"key": "KP2",
"command": ["print-text", "name: %n"],
"multiselect": true
},
{
"key": "KP3",
"command": ["print-text", "open directory: %p"]
},
{
"key": "KP4",
"command": ["print-text", "directory name: %d"]
},
{
"key": "KP5",
"command": ["print-text", "escape the code: %%f"],
"multiselect": true
},
{
"key": "KP6",
"command": ["print-text", "full filepath via concatenation: %p%n"],
"multiselect": true
},
{
"key": "KP7",
"command": ["print-text", "quote/escape filepath: %F"],
"multiselect": true
},


{
"comment": "deletes the currently selected file",
"key": "Alt+DEL",
"command": ["run", "rm", "%F"],
"filter": "file",
"command": ["script-message", "run-statement", "os.remove(%F) ; fb.rescan()"],
"multiselect": true,
"multi-type": "concat"
"multi-type": "repeat"
},
{
"comment": "opens the currently selected items in a new mpv window",
Expand All @@ -55,45 +19,22 @@
["run", "powershell", "-command", "Set-Clipboard", "%F"],
["print-text", "copied filepath to clipboard"]
],
"condition": "fb.get_platform() == 'windows'",
"api_version": "1.9.0",
"multiselect": true,
"delay": 0.3
},
{
"comment": "Opens the current directory in windows explorer",
"key": "Ctrl+o",
"command": ["run", "powershell", "-command", "explorer.exe", "(( %P ).TrimEnd('/') -replace '/', '\\' )"],
"multiselect": false
},
{
"comment": "Opens the selected directory in windows explorer",
"key": "Ctrl+O",
"command": ["run", "powershell", "-command", "explorer.exe", "(( %F ).TrimEnd('/') -replace '/', '\\' )"],
"filter": "dir",
"multiselect": true
},
{
"comment": "Opens the current directory in windows explorer and highlights the currently selected file",
"key": "Ctrl+O",
"command": ["run", "powershell", "-command", "explorer.exe", "'/select,'", "( %F -replace '/', '\\' )"],
"filter": "file",
"multiselect": true
},
{
"key": "INS",
"command": ["run", "powershell", "-command", "Set-Content", "-LiteralPath", "( %P + '/.ordered-chapters.m3u' )", "-Value", "( %N )"],
"multiselect": true,
"multi-type": "concat",
"concat-string": "+ '\n' +"
},


{
"key": "WHEEL_UP",
"command": ["script-binding", "file_browser/dynamic/scroll_up"]
"command": ["script-binding", "file_browser/dynamic/scroll_up"],
"flags": { "repeat": true }
},
{
"key": "WHEEL_DOWN",
"command": ["script-binding", "file_browser/dynamic/scroll_down"]
"command": ["script-binding", "file_browser/dynamic/scroll_down"],
"flags": { "repeat": true }
},
{
"key": "MBTN_LEFT",
Expand All @@ -106,13 +47,5 @@
{
"key": "MBTN_MID",
"command": ["script-binding", "file_browser/dynamic/play"]
},
{
"key": "UP",
"command": ["osd-auto", "add", "volume", "2"]
},
{
"key": "DOWN",
"command": ["osd-auto", "add", "volume", "-2"]
}
]
Loading