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