Wednesday 28 July 2021

Mantissa - Self capturing displacement shell-script

 This a shell-script I've been working on for a few days , it still needs a lot of tweaking so as presented this is just the rough version , but it does work , I'll post a video of it working on my peertube channel today and add a link later. And its later so heres the link https://tube.tchncs.de/w/1jrcqpHKgzg2AdafJ6upzz

What does it do ? The script first calls two web cams via stub scripts, the first at 1280x720 the second at 960x540 , placed in the centre of the screen. Its important to state that this is customised for a 1600x900 resolution widescreen monitor , and I've customised where terminals etc pop up and stay resident on that basis to leave the 1280x720 window in the middle of the screen clear for display and capture , you'll notice there's a third terminal called which runs the recording script which I use in conjunction with xdotool to maintain its focus. 

Once all that is running the cameras run continuously , both have a maximum resolution of 640x480 but running them via ffplay allows me to change that and that process gives some nice glitchy effects . The capturing section of the script first creates a seed file then moves to a loop until halted which takes the seed file and applies it in a loop to the video captured in real time , but always a step behind and using the real time capture as an input for a displacement function , so the displacement map created becomes more and more glitched out as the script continues , it also saves the files it creates to a secondary folder , so if you attempt to use this script you will need to change some values to reflect that and the size of your screen - xwininfo is your friend

All this on parabola running on a Dell 9010 with built in graphics , a 250gb ssd, 8gb ram and two playstation 3 cameras with no modifications ( though it runs with my circuit bent cameras quite well ) .

( you need the main script and two sub scripts in the same folder for this to run correctly )

Main script (mantissa.sh)

#! /bin/bash
# Note this works on 1600x900 res screen adjust win geometries by grabbing with xwininfo
i=0

lxterminal --geometry=17x24+0-32 -e ./mantissacam0.sh
sleep 10
lxterminal --geometry=17x24+0+0 -e ./mantissacam1.sh
lxterminal --geometry=17x24-0+0
sleep 30

# Grab seed file
xdotool mousemove 1525 6
xdotool mousedown 1
sleep 1
xdotool type "recordmydesktop -x 161 -y 112 --width 1280 --height 720 --v_quality 30 --overwrite --no-sound --on-the-fly-encoding -o mantissa-$i.ogv"
sleep 5
xdotool key Return
sleep 30
xdotool key ctrl+c
sleep 1

#save seed file
ffmpeg -i mantissa-$i.ogv -c:v libxvid -q 23 /home/crash-stop/mantissa/mantissa-seed.mp4

#main loop

while true
do
((i++))

#sleep 2
#get window corners and window size with xwininfo
xdotool mousemove 1525 6
xdotool mousedown 1
sleep 1
xdotool type "recordmydesktop -x 161 -y 112 --width 1280 --height 720 --v_quality 30 --overwrite --no-sound --on-the-fly-encoding -o mantissa-$i.ogv"
sleep 5
xdotool key Return
sleep 30
xdotool key ctrl+c
sleep 1

#ffmpeg -i mantissa-$i.ogv -c:v libxvid -q 23 /home/crash-stop/mantissa/mantissa-$i.mp4
ffmpeg -i mantissa-$i.ogv -i /home/crash-stop/mantissa/mantissa-seed.mp4 -lavfi '[1]split[x][y],[0][x][y]displace' /home/crash-stop/mantissa/mantissa-$i.mp4
mpv --geometry=1280x720+161+112 /home/crash-stop/mantissa/mantissa-$i.mp4
cp /home/crash-stop/mantissa/mantissa-$i.mp4 /home/crash-stop/mantissa/mantissa-seed.mp4
done

Subscript 1 (mantissacam0.sh)

#! /bin/bash

ffmpeg -i /dev/video1 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 - | sed 's/f/18/g' | ffplay -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 1280x720 -

Subscript 2 (mantissacam1.sh)  

#! /bin/bash
ffmpeg -i /dev/video0 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 - | sed 's/f/18/g' | ffplay -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 -


( Notice that the two subscripts also glitch the output of the two webcams using sed - obviously you can either remove that or change the values to alter effects )

Tuesday 6 July 2021

Install your freedom


TWM running on Parabola 


 
* April 2022. Note this guide is now woefully out of date. Recent changes to Parabolas install media , including the removal of the Lxde systemd iso image ( which was published in 2019) mean that the best way to install Parabola now is via the command line installer images on the parabola website which is more akin to doing a simple Arch Linux install. I will update this page once I've written a fresh guide. It is possible to use the guide I wrote below pre April  to get a fully running updated system but you end up with a system which has a few quirks that needs a lot of attention and removing a lot of out of date packages. 
 
The install guide I followed was the one on Parabolas own wiki here https://wiki.parabola.nu/Installation_Guide  but you will hit snags along the way due to keyring issues which I suggest you update before you get into the main installation proper - I used this as a guide to what was going on ( though its a discussion about the openrc version which is what I wanted to use but ended up for sanitys sake starting with the systemd version though I'm kind of opposed to systemd on philosophical grounds) https://labs.parabola.nu/boards/10/topics/1034
this is the important bit which updates the keyrings which seems to be the constant problem Parabola ( and Arch seems to have )
 
pacman -Sy archlinux-keyring parabola-keyring
and as it says lower down the same thread you may want to edit our old friend /etc/pacman.conf to 
SigLevel = Never 
 

Which should iron out any other errors - but as it doesn't say in the guide you will also want to do pacstrap /mnt nano to install nano so when we finally get to altering that file and later on in the chroot environment during the installation phase we have something to use. 

Installing everything will only give you a basic system without working networks or a graphical login or desktop environment so I would suggest before chrooting to the final stage   use pacstrap /mnt to install networkmanager network-manager-applet dhclient lxde lxdm wpa_supplicant sudo ( cos you don't want to have to keep using the root account ) and a few other file tools like ntfs-3g udisks2 pmount ( for that handy usb stick mounting routine ) and maybe just look at a few of the arch install documents to see if there's anything you might have missed this is the official arch wiki https://wiki.archlinux.org/title/Installation_guide you might be able to use this helper script but I didn't so I can't speak to its efficacy https://wiki.archlinux.org/title/Archinstall . And finally maybe after install add your user to the sudoers group via this guide - https://wiki.archlinux.org/title/Sudo and remember if you mess up and find something missing which stops you moving on to getting a fully working system you can always boot from the install medium and chroot into your installation ( the install medium includes networking so thats nice) and add in what you've missed .

Also take note that by default it seems none of the system services like networking or graphical login which are controlled via systemd are turned on by default so you will have to turn those on via the command line ie 'systemctl enable NetworkManager.service' for instance for the network manager to run at boot - handy if you want to say update your system or install packages, why isn't this on  by default, only the arch linux people can say, again it just seems like wilful perversity - it was so much easier using the live lxde iso .
 
As I say this is a quick guide to some of what I had to do to get the system up and running - I used a lot of the arch linux guides and made a lot of missteps because frankly speaking the Arch linux way of doing things is, coming from a Debian based distro  user perspective , perverse and once this project is over I'll be swapping to using Gnuinos which although on the fsf waiting list and not endorsed yet is way better and easier to use and by default doesnt use systemd. find Gnuinos here https://gnuinos.org/
 
 
* Note updated November 2021 as recent changes have led to a slight alteration in methodology described below for installation.
 
One of the many things lost after the release of Win 95 and earlier mac os versions was the focus on understanding computers rather than merely using them , we became users , customers of an ecosystem built up on selling us things that 'Just worked' rather than explorers working out how to do things for ourselves. This is no more  obvious than in the desktop paradigm of Win 95, mac os and later Android and ios where  everything sits within virtual folders, a simulacrum of a real office environment which is in effect what the computing paradigm became, a virtual cubicle to contain and constrain our thoughts and ideas.     This desktop as virtual cubicle paradigm can trap us within a way of working and thinking , yes I can change the desktop theme or the shape of the icons and cursors but what If I want to strip away layers of the Gui and say work without a taskbar or redesign the default font completely what if I want to step outside of my cubicle and do something different , something more exploratory.

 Over the last week to maintain compatibility with a project I'm collaborating on with Medialab , a project of Hacklab01 (more info here https://hacklab01.org/medialab ) I had to install a version of Linux that I hadn't used before - Parabola . Why Parabola? A lot of what I do and a lot of what Medialab works around are 'critical digital art creation' which naturally leads to the   ideas of open source software and the possibilities that it has.  Primary amongst that becomes the idea of libre-software as opposed to just open-source software. The difference is important , as the FSF states :

"As our society grows more dependent on computers, the software we run is of critical importance to securing the future of a free society. Free software is about having control over the technology we use in our homes, schools and businesses, where computers work for our individual and communal benefit, not for proprietary software companies or governments who might seek to restrict and monitor us." 

I've talked before about how the software I choose to use, and the uses I put it to are inherently political, but its not just the software I use it's also the operating system and the hardware I run that operating system on. 

Libre-software is fully free of licensing impediments or proprietary blobs. In the case of an operating system, which might require blobs to run things like wifi cards or graphics cards which are non-free - Parabola includes none of those things.  The FSF ( free software foundation here ) definition of what a libre operating system is :

" Free distributions (or “distros”) of the GNU/Linux system only include and only propose free software. They reject non-free applications, non-free programming platforms, non-free drivers, non-free firmware “blobs”, and any other non-free software and documentation. If they discover that by mistake some had been included, they remove it. "

Why is that important? If we want to work together its easier if we all speak the same language ie use the same or similar tools and the opportunity cost for anyone wanting to replicate or expand on what we do to be the same or similar ie as low as possible - art should be inclusive regardless of economic circumstances and  one of the mains ways to keep this inclusivity is to only use Libre software and as close as possible to Libre hardware or at least hardware that is serviceable. The point of Libre software is that it gives back our sense of the exploratory and control over what and how we produce   .

So lets download and install Parabola then install TWM , a desktop environment that  is unlike most of what we are familiar with today . The following guide is not my work , most of it was worked out By Vedran Gligo and the idea of using the TWM window manager comes from Dina Karadzic , one of the things that using libre software fosters is collaboration and so this a collaborative effort along with ideas taken from the Parabola community on reddit. 

NOTE - this is not a beginners guide , it assumes a working knowledge of Linux usage , hard drive partitioning, familiarity with using a command line   and a basic knowledge of the hardware you are using , though linux is free and libre-linux doubly so it requires you are willing to get your hands dirty .  If you haven't used linux yet I'd advise starting with Linuxmint, Debian or Manjaro just to gain a working familiarity with installing and using a linux desktop.

Download Parabola here - https://www.parabola.nu/ then read the installation guide here https://wiki.parabola.nu/Installation_Guide , its essential to read the installation guide and for beginners new to this I'd recommend downloading the Lxde image here as it gives a live distro to boot into and an easy installer program called calamares - I'd choose this one which is for 64 bit computers https://wiki.parabola.nu/Get_Parabola#Parabola_SystemD_LXDE_ISO, don't choose anything but that as the openrc images are known to be broken at this time and the cli net-installers involve a lot more specific knowledge ( if you can install arch via command-line you might get by but the issue that strikes is trickier to deal with from the command-line unless you really know what you are doing) 

Just as a by the by , I've installed this on a couple of Thinkpads , a T61 and an X200, both have had the bios whitelists removed , which is important as you will probably need to change out or source a libre distro  compatible wifi card, this isn't kansas anymore and some hardware that doesn't have opensource or libre drivers just won't work ( to get parabola to work on my dell optiplex 9010 I had to remove the Radeon graphics card and just rely on the inbuilt Intel one ) you can find a list of such things online but this is a guide to some of the issues you might encounter and what to look out for when deciding to use libre distros https://h-node.org/

So I'm going to assume you've downloaded and burnt parabola to cd or usb and are booting up the distro , you've followed and read the installation guide you've got to the lxde desktop and hit the installer button and have managed to follow it through and installed it to your computer , rebooted and logged in to your user account - this is where I hit the snag that took a couple of days to work out and without Vedran Gligos' help I would have given up or gone completely mad , as I said this ain't Kansas anymore . 

The first thing I do when I'm trying out a new distro is hit the package manager ( in Parabolas case the very fetching octopi and the command-line default pacman ) and that's what I did , to be met with some seriously scary error messages about keyservers and such like , which even using parabolas own troubleshooting guide  I could not get around. For what its worth the troubleshooting guide which in normal circumstances would have been all I needed is here - https://wiki.parabola.nu/Pacman_troubleshooting

Parabola like archlinux ( on which parabola is based )  validates its packages with pgp keys , and uses keyservers to check that these keys are still valid , so in parabolas case the keyserver that validates everything has gone offline and thus you have to do a bit of hacking around to update and install anything new not provided by the initial install which involves altering configuration files with root or superuser  privileges .

Step 1 ) open a terminal and do either ( depending on preference)

sudo leafpad /etc/pacman.conf

or 

sudo nano /etc/pacman.conf 

look for the line  'SigLevel    = Required DatabaseOptional'

comment that out and add in  a line saying 'SigLevel = TrustAll'

save and close that file then do 

sudo leafpad ( or nano) /etc/pacman.d/gnupg/gpg.conf

and add this line 'keyserver hkp://keyserver.ubuntu.com'

save and exit 

This is the important bit as this changes the default keyserver that the parabola package manager pacman looks to to validate keys .

step 2) Then from a terminal run these commands in sequence:

sudo pacman -Scc
sudo pacman -Syy archlinux-keyring archlinux32-keyring archlinuxarm-keyring parabola-keyring
sudo pacman-key --init
sudo pacman-key --populate archlinux archlinux32 archlinuxarm parabola
sudo pacman-key --refresh-keys

After the last command above you still get an error message but press on , all is well .  

* this is the first change to original guide - previously I had recommended that you 're-open /etc/pacman.conf and uncomment the line you commented out and comment out the line you added in ( you might need it at a later date !)' , leave the alteration to /etc/pacman.conf in place until AFTER doing step 3.

Step 3) Then from the terminal again type in 

'sudo pacman -Syu' - hit enter and watch your computer automagically retrieve packages and update itself 

Step 4)  Once that's all finished panic again as you will still get error messages  but all is not lost , you just have to open octopi and in the search bar type in linux-libre which pulls up the kernel , and re-install that. 

*Alteration to original guide . At this point Had recommended rebooting at this stage - but now we have to as well as reinstalling linux-libre we must also search octopi for parabola-keyrings and reinstall those ( its an updated keyring from October of 2021 which  might have led to the error I encountered which led to the rewrite of this guide ) 

after doing all that succesfully we can now go back  and 're-open /etc/pacman.conf and uncomment the line you commented out and comment out the line you added in ( you might need it at a later date !)'

So now with fingers crossed reboot and your computer should bring you back to the login screen . Ive done this at least three or four times in the last week and each time its worked , so I think we are golden. You should now have a fully functioning parabola linux system. 

Why step 4 ? the package manager installed and updated linux-libre kernel when I did 'sudo pacman -Syu '  - wellll It was explained to me that the update process above breaks the hooks the kernel needs to do things like updating grub etc so to avoid having to reboot from an emergency disk and chroot into the system if we re-install the kernel using octopi before rebooting it repairs the errors created by the initial update which fixes the keyserver issue - hopefully you won't have to do this again , even if the kernel is updated at a later stage .

This took a few days for Vedran to work out by which time I'd almost forgotten why I was wanting to use this system in the first place. 

Was all of this heartache and hair pulling worth it ? I'd have to say yes , because now I have system which is lean, powerful and actually useful plus now I can try out ideas before committing them to the main project ( which runs on an online version of Parabola )  knowing that if they work on this computer without breaking it they will work on the remote computer , and that's the point - compatibility and reproducibility all from free and libre software .

So with that out of the way I can now install what I came here for which is a window manager called TWM and compared to the above installation is a breeze. But why TWM ? Its low on resource usage ( I have this whole distro running on my T61 which was built in 2009 and it just works well ) aaaand it looks and behaves unlike Windows xx or Mac os xx or ios or android - its easily customizable from a small and simple configuration script , one of the great things about linux is that it gives you back the power to alter scripts and files easily, and in my case explore the edges of what can be done such as these :

Twm running before starting xsetroot

Twm after running xsetroot below !




Just by adding a few simple programs like xsetroot and running them the desktop becomes a visual environment or paintbox leaving trails after opened windows and composing itself as I use and open windows .

How to install TWM ? theres a good guide here https://wiki.archlinux.org/title/Twm and there some good guides to basic .twmrc configurations here http://www.xwinman.org/








 

ikillerpulse ( requires tomato.py in working directory)

I've been working on this script for the last week or so. What does it do? It takes an input video/s,  converts to a format we can use f...