diff --git a/README.md b/README.md index 3cafbfde..60a9dcdc 100644 --- a/README.md +++ b/README.md @@ -29,58 +29,54 @@ Most notable features: [Changelog](https://github.com/tomasklaen/uosc/releases). -## Download +## Installation -- [`uosc.zip`](https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip) - main archive with script and its requirements -- [`uosc.conf`](https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf) - configuration file with default values and documentation +1. These commands will install or update **uosc** and place a default `uosc.conf` file into `script-opts` if it doesn't exist already. -## Installation + ### Windows -1. Extract `uosc.zip` into your mpv config directory. + _Optional, needed to run a remote script the first time if not enabled already:_ - _List of all the possible places where it can be located is documented here: https://mpv.io/manual/master/#files_ + ```powershell + Set-ExecutionPolicy RemoteSigned -Scope CurrentUser + ``` - On Linux and macOS these terminal commands can be used to install or update uosc (if wget and unzip are installed): + Run: - ```sh - config_dir="${XDG_CONFIG_HOME:-~/.config}" - mkdir -pv "$config_dir"/mpv/script-opts/ - rm -rf "$config_dir"/mpv/scripts/uosc_shared - wget -P /tmp/ https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip - unzip -od "$config_dir"/mpv/ /tmp/uosc.zip - rm -fv /tmp/uosc.zip + ```powershell + irm https://raw.githubusercontent.com/tomasklaen/uosc/HEAD/installers/windows.ps1 | iex ``` - On Windows these equivalent PowerShell commands can be used: - ```PowerShell - New-Item -ItemType Directory -Force -Path "$env:APPDATA/mpv/script-opts/" - $Folder = "$env:APPDATA/mpv/scripts/uosc_shared" - if (Test-Path $Folder) { - Remove-Item -LiteralPath $Folder -Force -Recurse - } - Invoke-WebRequest -OutFile "$env:APPDATA/mpv/uosc_tmp.zip" -Uri https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip - Expand-Archive "$env:APPDATA/mpv/uosc_tmp.zip" -DestinationPath "$env:APPDATA/mpv" -Force - Remove-Item "$env:APPDATA/mpv/uosc_tmp.zip" + **NOTE**: If this command is run in an mpv installation directory with `portable_config`, it'll install there instead of `AppData`. + + ### Linux & macOS + + _Requires **curl** and **unzip**._ + + ```sh + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/tomasklaen/uosc/HEAD/installers/unix.sh)" ``` -2. **uosc** is a replacement for the built in osc, so that has to be disabled first. + ### Manual + + 1. Download & extract [`uosc.zip`](https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip) into your mpv config directory. (_See the [documentation of mpv config locations](https://mpv.io/manual/master/#files)._) - In your `mpv.conf` (file that should already exist in your mpv directory, if not, create it): + 2. If you don't have it already, download & extract [`uosc.conf`](https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf) into `script-opts` inside your mpv config directory. It contains all of uosc options along with their default values and documentation. + +2. **OPTIONAL**: `mpv.conf` tweaks to better integrate with **uosc**: ```config - # required so that the 2 UIs don't fight each other - osc=no - # uosc provides its own seeking/volume indicators, so you also don't need this + # uosc provides seeking & volume indicators (via flash-timeline and flash-volume commands) + # if you decide to use them, you don't need osd-bar osd-bar=no - # uosc will draw its own window controls if you disable window border + + # uosc will draw its own window controls and border if you disable window border border=no ``` -3. To configure **uosc**, create a `script-opts/uosc.conf` file, or download `uosc.conf` with all default values from the link above, and save into `script-opts/` folder. - -4. **OPTIONAL**: To have thumbnails in timeline, install [thumbfast](https://github.com/po5/thumbfast). That's it, no other step necessary, **uosc** integrates with it seamlessly. +3. **OPTIONAL**: To have thumbnails in timeline, install [thumbfast](https://github.com/po5/thumbfast). No other step necessary, **uosc** integrates with it seamlessly. -5. **OPTIONAL**: If the UI feels sluggish/slow while playing video, you can remedy this a lot by placing this in your `mpv.conf`: +4. **OPTIONAL**: If the UI feels sluggish/slow while playing video, you can remedy this _a bit_ by placing this in your `mpv.conf`: ```config video-sync=display-resample @@ -90,11 +86,11 @@ Most notable features: #### What is going on? - **uosc** places performance as one of its top priorities, so how can the UI feel slow? Well, it really isn't, **uosc** is **fast**, it just doesn't feel like it because when video is playing, the UI rendering frequency is chained to its frame rate, so unless you are the type of person that can't see above 24fps, it _will_ feel slow, unless you tell mpv to resample the video framerate to match your display. This is mpv limitation, and not much we can do about it on our side. + **uosc** places performance as one of its top priorities, but it might feel a bit sluggish because during a video playback, the UI rendering frequency is chained to its frame rate. To test this, you can pause the video which will switch refresh rate to be closer or match the frequency of your monitor, and the UI should feel smoother. This is mpv limitation, and not much we can do about it on our side. ## Options -All of the available **uosc** options with their default values and documentation are in the provided `uosc.conf` file. +All of the available **uosc** options with their default values are documented in [`uosc.conf`](https://github.com/tomasklaen/uosc/blob/HEAD/script-opts/uosc.conf) file ([download](https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf)). To change the font, **uosc** respects the mpv's `osd-font` configuration. diff --git a/installers/unix.sh b/installers/unix.sh new file mode 100644 index 00000000..ce161e30 --- /dev/null +++ b/installers/unix.sh @@ -0,0 +1,58 @@ +#!/bin/bash +zip_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip +conf_url=https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf +zip_file=/tmp/uosc.zip + +# Exit immediately if a command exits with a non-zero status +set -e + +cleanup() { + if [ -f "$zip_file" ]; then + echo "Deleting: $zip_file" + rm -f $zip_file + fi +} + +abort() { + cleanup + echo "Error: $1" + exit 1 +} + +# Check OS +OS="$(uname)" +if [ "${OS}" == "Linux" ]; then + data_dir="${XDG_CONFIG_HOME:-$HOME/.config}/mpv" +elif [ "${OS}" == "Darwin" ]; then + data_dir=~/Library/Preferences/mpv +else + abort "This install script works only on linux and macOS." +fi + +# Ensure directory exists +mkdir -pv $data_dir + +# Remove old and deprecated folders & files +echo "Deleting old and deprecated uosc files and directories." +rm -rf "$data_dir/scripts/uosc_shared" || abort "Couldn't cleanup old files." +rm -rf "$data_dir/scripts/uosc" || abort "Couldn't cleanup old files." +rm -f "$data_dir/scripts/uosc.lua" || abort "Couldn't cleanup old files." + +# Install new version +echo "Downloading: $zip_url" +curl -L -o $zip_file $zip_url || abort "Couldn't download the archive." +echo "Extracting: $zip_file" +unzip -od $data_dir $zip_file || abort "Couldn't extract the archive." +cleanup + +# Download default config if one doesn't exist yet +scriptopts_dir="$data_dir/script-opts" +conf_file="$scriptopts_dir/uosc.conf" +if [ ! -f "$conf_file" ]; then + echo "Config not found, downloading default one..." + mkdir -pv $scriptopts_dir + echo "Downloading: $conf_url" + curl -L -o $conf_file $conf_url || abort "Couldn't download the config file, but uosc should be installed correctly." +fi + +echo "uosc has been installed." diff --git a/installers/windows.ps1 b/installers/windows.ps1 new file mode 100644 index 00000000..7ad195fe --- /dev/null +++ b/installers/windows.ps1 @@ -0,0 +1,94 @@ +$ZipURL = "https://github.com/tomasklaen/uosc/releases/latest/download/uosc.zip" +$ConfURL = "https://github.com/tomasklaen/uosc/releases/latest/download/uosc.conf" + +# Portable vs AppData install +if (Test-Path "$PWD/portable_config") { + $DataDir = "$PWD/portable_config" + Write-Output "Portable mode: $DataDir" +} +elseif ((Get-Item -Path $PWD).BaseName -eq "portable_config") { + $DataDir = "$PWD" + Write-Output "Portable mode: $DataDir" +} +else { + $DataDir = "$env:APPDATA/mpv" + Write-Output "AppData mode: $DataDir" + if (!(Test-Path $DataDir)) { + Write-Output "Creating folder: $DataDir" + New-Item -ItemType Directory -Force -Path $DataDir > $null + } +} + +$ZipFile = "$DataDir/uosc_tmp.zip" + +Function Cleanup() { + try { + if (Test-Path $ZipFile) { + Write-Output "Deleting: $ZipFile" + Remove-Item -LiteralPath $ZipFile -Force + } + } + catch {} +} + +Function Abort($Message) { + Cleanup + Write-Output "Error: $Message" + Exit 1 +} + +# Remove old or deprecated folders & files +try { + $UoscDir = "$DataDir/scripts/uosc" + $UoscDeprecatedDir = "$DataDir/scripts/uosc_shared" + $UoscDeprecatedFile = "$DataDir/scripts/uosc.lua" + if (Test-Path $UoscDir) { + Write-Output "Deleting old: $UoscDir" + Remove-Item -LiteralPath $UoscDir -Force -Recurse + } + if (Test-Path $UoscDeprecatedDir) { + Write-Output "Deleting deprecated: $UoscDeprecatedDir" + Remove-Item -LiteralPath $UoscDeprecatedDir -Force -Recurse + } + if (Test-Path $UoscDeprecatedFile) { + Write-Output "Deleting deprecated: $UoscDeprecatedFile" + Remove-Item -LiteralPath $UoscDeprecatedFile -Force + } +} +catch { + Abort("Couldn't cleanup old files.") +} + +# Install new version +try { + Write-Output "Downloading: $ZipURL" + Invoke-WebRequest -OutFile $ZipFile -Uri $ZipURL > $null +} +catch { + Abort("Couldn't download the archive.") +} +try { + Write-Output "Extracting: $ZipFile" + Expand-Archive $ZipFile -DestinationPath $DataDir -Force > $null +} +catch { + Abort("Couldn't extract the archive.") +} +Cleanup + +# Download default config if one doesn't exist yet +try { + $ScriptOptsDir = "$DataDir/script-opts" + $ConfFile = "$ScriptOptsDir/uosc.conf" + if (!(Test-Path $ConfFile)) { + Write-Output "Config not found, downloading default one..." + New-Item -ItemType Directory -Force -Path $ScriptOptsDir > $null + Write-Output "Downloading: $ConfURL" + Invoke-WebRequest -OutFile $ConfFile -Uri $ConfURL > $null + } +} +catch { + Abort("Couldn't download the config file, but uosc should be installed correctly.") +} + +Write-Output "uosc has been installed."