Samstag, 13. Juni 2015

Linux, minimal WIFI on Laptop

Every now and then i do a new installation or try out a new (or new version of an already known) distro.

The most irritating part with many linux installations is the following:

They provide wifi tools on the install image, but they are not part of the core system to be installed.

The core system expects a desktop computer, or just any device having a wired only connection to the internet (or LAN for that reason) .

So, first of a remainder of the packages required:
  • dhcpcd, and ifconfig (or ip) (should already be installed)
  • wpa_supplicant
  • iw

As for all my scripts, it uses TUI, so you might want to install GIT or just download it from the http://github.com/sri-arjuna/tui page.

Now, the concept is, to have one script per spot, and have logfiles for each of the spots.

The logfiles are created according to the script its name, and create the key (creds) file automaticly if its missing.

Add the missing pieces, AP, password and your wifi device.

Then, save the code as something like: wifi-home.
#!/bin/bash
#
#    Variables
#
    WIFI=wlp3s0        # Your WIFI device
    SSID="AP-name"    # The AP its name
    PASS="AP-pass"        # Password for that AP
    URL="google.com"    # Which URL to ping
    ME=${0##*/}
    KEY="$HOME/.config/$ME.key"    # Where to save the keyfile
    #
#    Internals
#
    start=${start:-false}
    [ 0 -eq ${UID:-0} ] && \
        LOG=/var/log/$ME.log || \
        LOG=$HOME/.local/logs/$ME.log
#
#    Functions
#
    wifi_createkey () { # SSID PASS FILE
    # Creates a wpa key file if none exists yet
    #
        [ -d "$(dirname $3)" ] || mkdir -p "$(dirname $3)"
        wpa_passphrase "$1" "$2" > "$3"
    }
    wifi_start() {
    # Start wpa supplicant in background
    #
        wpa_supplicant -B -i$WIFI -c"$KEY" 1>>"$LOG" 2>>"$LOG" &
        dhcpcd -B 1>>"$LOG" 2>>"$LOG"
    }
    p() { ping -c 1 "$URL" 1>/dev/zero 2>/dev/zero;}
#
#    Display and action
#
    # Is there a key file?
    [ ! -f "$KEY" ] && wifi_createkey "$SSID" "$PASS" "$KEY"

    # If it cant ping, then there is no internet
    if ! p 1>/dev/zero 2>/dev/zero
    then    start=true
        # If they are already running, they are blocking the new connection
        for used in dhcpcd ${0##*/}
        do    # Make sure those processes are killed if they are still running
        if ps|grep $used | grep -v $$ >/dev/zero && tui-yesno "$used is already running, stop it?"
        then    pkill $used
            kill $(ps|awk -v user=$used '/used/ {print $1}')
        fi
        done
    fi

    # Now only start if we need to
    if $start
    then    tui-status -r 2 "Starting WIFI..."
        wifi_start &
        tui-status $? "Started wifi"
    fi
Now lets prepare that thing to be executed upon boot, prepare:
[Unit]
Description=Wifi-Home

[Service]
Type=oneshot
ExecStart=/path/to/script/wifi-home.sh

[Install]
WantedBy=multi-user.target
And place it in /etc/systemd/system as wifi-home.service.
And now finaly as root:
systemctl enable wifi-home
systemctl start wifi-home
Et voila, you should now have wifi at each new boot.

After a restart, you can check how long the loading took:

$ systemd-analyze critical-chain

The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.

graphical.target @12.509s
└─multi-user.target @12.508s
  └─wifi-home.service @11.729s +778ms
    └─basic.target @11.382s
   ...





Hope this helps

Montag, 8. Juni 2015

ARCH: Ugly fonts in Firefox?

Oh yeah, some pages are hard to read with such pixelish fonts...

Smooth and easy solution, is to disable the bitmap fonts, which are often linked to the 75 and 100 dpi fonts.
su
ln -s  /etc/fonts/conf.avail/70-no-bitmaps.conf \
  /etc/fonts/conf.d/

Montag, 1. Juni 2015

Incoming update for VHS

Not yet done, but i'm excited about the latest achievement.

Playing multiple audio files works now, and updated its playback quite a bit, but see for yourself:





The progressbar beeing on multiple lines, was caused by pressing enter, so you see the 'progress ' too.

Enjoy

Samstag, 30. Mai 2015

One for between

The is a simple example how to read directly from a list file and check if that variable exists as directory.
If that is true, if writes to the tasklist, if not, it writes to another list.

Since one can pass multiple arguments to touch, one can even use parameter expansion to create multiple files at once.

#!/bin/bash
DATA="$HOME/data"
LIST="$DATA/mylist.txt"
JOB_NO="$DATA/job_no.txt"
JOB_YES="$DATA/job_yes.txt"

[ -d "$DATA" ] || mkdir -p "$DATA"
touch $JOB_{NO,YES} $LIST

while read dirfolder
do    [ -d "$dirfolder" ] && \
    echo "$dirfolder" >> "$JOB_YES" || \
    echo "$dirfolder" >> "$JOB_NO"
done<"$LIST"

Have fun

Building libdvdcss

My favorite linux distribution Fedora has a release cycle of roughly 6 months, and i tend to twink often too much with that running system i actualy would have had attainted...

It just so happens that i quite often (re-) install the OS even if its just to try the fresh built LiveOS.
Anyway, figured named LiveOS could not succeed because one of the rpm repositries was ready with that just yet.

How nice, for that i figured, that download and comile libdvdcss is easier than to run after the latest package specificly for my OS.

One has to be aware however, that my system is a developer oriented machine, so most of the required applications were already installed.
A good point to start would be:

On Fedora for example:
sudo dnf install make autoconf automake gcc
Then simply save the below code as a script, and execute it after a fresh installation.
git clone git://git.videolan.org/libdvdcss
cd libdvdcss
autoreconf -i
./configure --prefix=/usr
make && sudo make install

Hope this helps

Freitag, 29. Mai 2015

TUI update 0.8.1-4

  • Changed:   tui-new-*, had some invalid references left
  • Changed:   tui-new-*, added some default values to settings.conf, like which templatefile to use if no arguments are passed
  • Changed:   tui-filemgr, got forgotten when changed to list files
Get it at https://github.com/sri-arjuna/tui/releases/tag/v0.8.1-4
Or update it like:
su
cd /path/to/tui-git-repositry
git pull
echo y n | ./install.sh
 

Mittwoch, 27. Mai 2015

TUI v0.8.1-3 (stable hotfix)

Taming the beast was a hard feast, it was a wild one with wit.
The horse is back to the stable, and baby i smile like Clark Gable.

https://github.com/sri-arjuna/tui/releases/tag/v0.8.1-3

It should be back to were it was before the RC file.