Sonntag, 27. September 2015

How to start coding GNU/Linux software

An often asked question is:

How do i start coding for the GNU/Linux community?

Well, assuming you already can write code, we can focus on GNU/Linux specific issues.

First read:
Coding Standards: http://www.gnu.org/prep/standards/html_node/
Translating using gettext: http://www.gnu.org/software/gettext/manual/gettext.html

While preparing your documention:
texinfo: http://www.gnu.org/software/texinfo/manual/texinfo/texinfo.html

Then, with your first example project following those guide lines, go ahead and dig into:
Autconf: http://www.gnu.org/software/autoconf/manual/autoconf.html
Automake: http://www.gnu.org/software/automake/manual/automake.html
These tools will help to compile your project at the enduser side without issues.

I figured the hard way, created a project, and then had to apply (at least some of) these standards afterwards.. which caused lots of unrequired work...


Other than that, try to make something new, not yet another media converter based upon ffmpeg or avutils.
To do so, search the already existing software at:
Of course, just as/for a training project, you can do whatever you like, just dont expect anyone to jump around in that case.

Hope this helps

Montag, 21. September 2015

YASSI 1.0.1 - Final release

I'm happy to announce the final release of YASSI.

YASSI does not need to be installed, unless you want to 'info yassi'.
The project name and version 'yassi'/1.0.1, and both lines with 'Report bugs...' are read from the configuration file,
and therefor will adjust to your project settings.
Not even 2 months ago I had started with this project, and it already provides all the functions i've wanted for it.While I initially started it for another project of mine where i needed to focus on the duty, i wanted to have it as its own project, to use with ther projects.

I do hope you helps you as much as it does for me.

What is YASSI again?

Yet Another Simple Script Installer

What is it for?

It requires a single file to provide all information for an installation custom to your needs,
while staying easy change-able by the end user.

Get it


Donnerstag, 17. September 2015

Funny error message

Been trying to write a task manager for a script, with the recent changes for GNU TUI evalutation, this is an error i've recieved while working on VHS (Video Handler Script, using ffmpeg)...
Wondering if my security concerns were too much... 

The german words means: "Line 224: .. Syntax  Error: Operator expected. (Error causing character is \033[....)"




So basicly, aborting failed because the aborting text string for the user contained a smiley ';)'
While mainwhile the the printing fails due to an unprintable character, escape string.
But the aborting, after all, aborts successfull.

Usualy errors are just annoying, but this one i found rather funny.

BTW, these 3 bugs are fixed now.

Learn about TUI
Learn about VHS

Download them at github.

Dienstag, 8. September 2015

Minimalistic prompt (PS1)

The most usefull and minimalstic command prompt i can imagine for scripters or sys-admins:
PROMPT_COMMAND='RET=$?'
RET_VAL="$(echo $RET)"
export PS1="$RET_VAL \\$ "
If if its within a terminal window, you'll see the path you're in in the task- or titlebar.
If you really want to have the path in your shell, try this line:
export PS1="$RET_VALUE \W \\$ "

Hope you enjoy and have fun!

Montag, 3. August 2015

Yet Another Simple Script Installation

Got a cool script, and now need an installation script?

YASSI helps you :)
Inspired by the powerfull, but complex, GNU Autotool's, i've written this single script to handle this.

Main benefit?
It requires just a single configuration file.

Main drawback?
Its just to place the files, it does NOT do ANY compiling.

Read all about it, in the README.md

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/