diff --git a/README.md b/README.md index 0da6288..68ae865 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Fix Opera Linux ffmpeg & WidevineCdm -* Fix Opera html5 media content +* Fix Opera html5 media content including DRM-protected one. * It script must be execute all times opera will fails on showing html5 media content. -* Now it also fixes WidevineCdm support for DRM video. You can try it on Vevo youtube channel for example. +* On Debian-based and Arch-based distros it may be started automatically after Opera update. ## Requirements @@ -22,35 +22,7 @@ ```cd ./fix-opera-linux-ffmpeg-widevine``` -3. (*Optional*) You may disable **Widevine** fix if one that comes with Opera works well for you. - - ```sed -i '/FIX_WIDEVINE=/s/true/false/g' ./fix-opera.sh``` - -4. Run script. And if it works well got ot next step. +3. Run install script and answer few questions. - ```sudo ./fix-opera.sh``` + ```sudo ./install.sh``` -5. Create a **.scripts** folder on **root**'s **home** - - ```sudo mkdir ~root/.scripts``` - -6. Copy the script into the **.scripts** folder - - ```sudo cp ./fix-opera.sh ~root/.scripts``` - -7. Choose one or both options - * (*Optional*) Create an **alias**. And then you'll be able to start it by typing ```fix-opera``` command in terminal. - - ```echo "alias fix-opera='sudo ~root/.scripts/fix-opera.sh' # Opera fix HTML5 media" >> ~/.bashrc``` - - ```source ~/.bashrc``` - - * (*Optional*) Autostart after each opera upgrade (Debian-based distros) - - ```sudo cp ./99fix-opera ~root/.scripts``` - - ```sudo ln -s ~root/.scripts/99fix-opera /etc/apt/apt.conf.d/``` - -8. Delete the repo - - ```cd .. && rm -rf ./fix-opera-linux-ffmpeg-widevine``` diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..fa5d638 --- /dev/null +++ b/install.sh @@ -0,0 +1,85 @@ +#!/bin/bash +if [[ $(whoami) != "root" ]]; then + printf 'Try to run it with sudo\n' + exit 1 +fi + +readonly SCRIPT_PATH=$(dirname $(readlink -f $0)) +readonly INSTALL_PATH="/root/.scripts" +readonly USER_NAME="$(logname)" +readonly USER_HOME=$(sudo -u $USER_NAME sh -c 'echo $HOME') + +create_hook () +{ + printf 'Choose your Linux distro:\n' + printf ' 1. Debian-based (Debian/Ubuntu/Mint/etc.)\n' + printf ' 2. Arch-based (Arch/Manjaro/etc.)\n' + printf ' 0. Other\n' + while read -p "Your choice: " DISTRIB; do + case $DISTRIB in + "1" ) + cp -f $SCRIPT_PATH/scripts/99fix-opera $INSTALL_PATH + ln -sf $INSTALL_PATH/99fix-opera /etc/apt/apt.conf.d/ + break;; + "2" ) + cp -f $SCRIPT_PATH/scripts/fix-opera.hook $INSTALL_PATH /usr/share/libalpm/hooks + ln -sf $INSTALL_PATH/fix-opera.hook /usr/share/libalpm/hooks/ + break;; + "0" ) + printf "Autostart for your Linux distro is currently unsupported\n" + break;; + * ) + continue;; + esac + done +} + +printf 'Would you like to apply Widevine CDM fix? [y/n]' +while read FIX_WIDEVINE; do + case $FIX_WIDEVINE in + "y" | "Y") + printf 'Setting FIX_WIDEVINE to true...\n' + sed -i '/FIX_WIDEVINE=/s/false/true/g' $SCRIPT_PATH/scripts/fix-opera.sh + break;; + "n" | "N") + printf 'Setting FIX_WIDEVINE to false...\n' + sed -i '/FIX_WIDEVINE=/s/true/false/g' $SCRIPT_PATH/scripts/fix-opera.sh + break;; + * ) + printf 'Would you like to apply Widevine CDM fix? [y/n]' + continue;; + esac +done + +mkdir -p $INSTALL_PATH +cp -f $SCRIPT_PATH/scripts/fix-opera.sh $INSTALL_PATH + +printf "Would you like to create an alias for user $USER_NAME? [y/n]" +while read CREATE_ALIAS; do + case $CREATE_ALIAS in + "y" | "Y") + echo "alias fix-opera='sudo ~root/.scripts/fix-opera.sh' # Opera fix HTML5 media" >> $USER_HOME/.bashrc + printf "Alias will be available after your next logon.\n" + break;; + "n" | "N") + break;; + * ) + printf "Would you like to create an alias for user $USER_NAME? [y/n]" + continue;; + esac +done + +printf "Would you like to run it automatically after each Opera update? [y/n]" +while read CREATE_HOOK; do + case $CREATE_HOOK in + "y" | "Y") + create_hook + break;; + "n" | "N") + break;; + * ) + printf "Would you like to create an alias for user $USER_NAME? [y/n]" + continue;; + esac +done + diff --git a/99fix-opera b/scripts/99fix-opera similarity index 76% rename from 99fix-opera rename to scripts/99fix-opera index 676b6e9..b2a5350 100644 --- a/99fix-opera +++ b/scripts/99fix-opera @@ -1,2 +1,2 @@ DPkg::Pre-Invoke {"stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera > /tmp/opera.timestamp";}; -DPkg::Post-Invoke {"if [ `stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera` -ne `cat /tmp/opera.timestamp` ]; then ~root/.scripts/fix-opera.sh; fi; rm /tmp/opera.timestamp";}; +DPkg::Post-Invoke {"if [ `stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera` -ne `cat /tmp/opera.timestamp` ]; then /root/.scripts/fix-opera.sh; fi; rm /tmp/opera.timestamp";}; diff --git a/scripts/fix-opera.hook b/scripts/fix-opera.hook new file mode 100644 index 0000000..e0ed4aa --- /dev/null +++ b/scripts/fix-opera.hook @@ -0,0 +1,12 @@ +# Fix video playback on Opera Upgrade/Install. + +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = opera + +[Action] +Description = Fix video playback in Opera browser +When = PostTransaction +Exec = /root/.scripts/fix-opera.sh diff --git a/fix-opera.sh b/scripts/fix-opera.sh similarity index 100% rename from fix-opera.sh rename to scripts/fix-opera.sh