Labels

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, 9 September 2018

Boot openSUSE Tumbleweed faster

Change compression method for initrd, as root:
echo 'compress="cat"' >/etc/dracut.conf.d/99-compress.conf
dracut --force

And if you're not using YaST to configure network setup, Networkmanager might speed up boot a bit compared to Wicked, as root:
systemctl enable NetworkManager && systemctl disable wicked

Sunday, 8 October 2017

Fix Gnome (/Xorg) 3.24/3.26 stutter on NVIDIA

..By recompiling mutter without threaded GL sync.
From the source tree:

  1. cd mutter-3.26.1/
  2. cp src/backends/x11/meta-renderer-x11.c src/backends/x11/meta-renderer-x11.c.orig
  3. sed 's/cogl_xlib_renderer_set_threaded_swap_wait_enabled (cogl_renderer, TRUE/cogl_xlib_renderer_set_threaded_swap_wait_enabled (cogl_renderer, FALSE/' -i src/backends/x11/meta-renderer-x11.c


Now compile, install and restart it..

The problem arise from a timing issue.

Sunday, 19 February 2017

Re-encode audio to AAC, in a bunch of mkv files..

..as fast as bandwidth to the fileserver can allow, running encodes in parallel up to amount of processors. AAC seems compatible with HW decoders everywhere + also with Chromebooks, which invited me to create this:

#!/bin/bash -e

TEMP=/fast/temp
DOWN=2 #allow 1 more than max 'uploads' to keep encoding busy
UP=1 #limit in order to write in a streamlined fashion rather than trashing NAS/FS, due to potential race condition +1 might happen

[[ -z $1 ]] && echo "Usage: $0 <file> [file] [file].." && exit 0
FAACS=$(nproc)
PGID=$$ #limit scope for pgrep
cd "$TEMP"

sleeprnd() { echo $((RANDOM % ($(pgrep -xcg $PGID sleep)+1) +1)); } #random secs between 1 .. amount of sleep processes we're running
waitcount() { while [[ $(pgrep -xcg $PGID $1) -ge $2 ]]; do sleep $(sleeprnd); done; }
re-encode() {
        ORIG="$1"
        BASE="$(basename "$ORIG" .mkv)"
        LOCAL="$BASE"_orig.mkv
        DEST="$(dirname "$ORIG")"/"$BASE"_aac.mkv
        #now wait for ample space to be available @TEMP
        until [[ $(df --output=avail "$TEMP" | tail -n 1) -gt $(( 7 * $(du "$ORIG" | sed -e 's/\t.*//g') )) ]]; do sleep $(sleeprnd); done
        waitcount cp $DOWN; cp -v "$ORIG" "$LOCAL"
        mkvmerge --no-audio "$LOCAL" -o "$BASE"_noaudio.mkv
        for TRACK in $(mkvmerge -i "$LOCAL" | grep ': audio' | sed -e 's/:.*//g' -e 's/.* //g'); do
                mkvextract tracks "$LOCAL" $TRACK:"$BASE"_audio
                waitcount faac $FAACS; ffmpeg -v 0 -i "$BASE"_audio -f wav - \
                        | faac -b 160 - -o "$BASE"_audio_$TRACK.aac &>/dev/null
        done
        mkvmerge "$BASE"_noaudio.mkv "$BASE"_audio_*.aac -o "$BASE".new.mkv
        rm "$BASE"_*
        waitcount cp $UP; cp -v "$BASE".new.mkv "$DEST"
        touch "$DEST" -r "$ORIG"
        #mv "$DEST" "$ORIG"
        echo "$ORIG" >>/dev/shm/ramdisk/log
        rm "$BASE".new.mkv
}

while [[ -n "$1" ]]; do
        re-encode "$1" &
        sleep 1
        shift
done

wait

Monday, 31 October 2016

systemctl, journalctl breaking bad

Since systemctl and journalctl are bad by breaking scrolling by default (using a pager).

Do this as root to become sane again:
echo SYSTEMD_PAGER= >>/etc/environment

Log out and back in.

Friday, 18 March 2016

makemkv wrapper with auto updater

Installs to home folder, creates usr folder under $HOME/.
Does not require root.
Requires xclip to dump latest beta key to "selection" (middle click "clipboard").
Launches makemkv if build succeeded or if already at latest version.

#!/bin/bash

echo $HOME
cd $HOME
URL='http://www.makemkv.com/forum2/viewtopic.php?f=3&t=224'
[[ -n "$1" ]] \
        && VERSION=$1 \
        || VERSION=$(curl --silent "$URL" | grep MakeMKV.*for.Linux.is | head -n 1 | sed -e 's/.*MakeMKV //g' -e 's/ .*//g')

KEY=$(curl --silent 'http://www.makemkv.com/forum2/viewtopic.php?f=5&t=1053'| grep T-|sed -e 's/.*codecontent..//g' -e 's/..div. .*//g')
echo "key: $KEY"
echo "$KEY" | xclip

if [[ "$VERSION" = "$(cat $HOME/.makemkv-version)" ]]; then
        echo MakeMKV is up to date.
else
        for r in oss bin; do
                wget -c "http://www.makemkv.com/download/makemkv-$r-$VERSION.tar.gz"
                tar xf makemkv-$r-$VERSION.tar.gz
                cd makemkv-$r-$VERSION
                [[ "$r" = "oss" ]] && ./configure || { mkdir -p tmp; echo accepted >tmp/eula_accepted; }
                make -j 17 install DESTDIR=$HOME/ || { echo -e "###\n### Error occurred, maybe missing build deps?\n### $URL\n###"; sleep 30; exit 1; }
                cd ..
        done
fi

env LD_LIBRARY_PATH=usr/bin:usr/lib:usr/share:usr QT_PLUGIN_PATH=/usr/lib/kde4/plugins:$QT_PLUGIN_PATH usr/bin/makemkv \
        && echo $VERSION | tee $HOME/.makemkv-version

Saturday, 1 January 2011

Ubuntu 10.10 autologin, CLI way

First, be root
sudo -i
Copy the example
cp /usr/share/doc/gdm/examples/custom.conf /etc/gdm/
Edit it with your favourite editor
vim /etc/gdm/custom.conf
Add lines like these under [daemon]
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=username

Thursday, 1 July 2010

Ubuntu (10.04) custom power button event

Update 14. Oct. 2010: Works in Ubuntu 10.10 as well.

To poweroff only if the power button is pressed twice - change /etc/acpi/powerbtn.sh like this:

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.
# you need to double 'click' the power button to shutdown
( if ! [ $(pidof -x powerbtn.sh | wc -w) -eq 3 ]; then
        sleep .4
        exit
else
        poweroff
fi) &


It won't ask silly questions either - just shutdown now.
Now remove the wire from the reset button to make it more kid proof.