Thursday, 29 September 2022

Steam not starting from Cinnamon launcher

 Just upgraded to 22.04.1 LTS and of course that broke a lot of stuff.


In this case it was Steam (installed via apt repository)


Steam would start successfully from a terminal but would fail if launched from a launcher in Cinnamon. Further investigation showed that the steam process would be marked "defunct" after such a failure.

My initial workaround was to change the launcher to "Run in terminal" which worked OK but is kind of messy.

A better "fix" is to edit this file;

<code>sudo vi /usr/share/applications/steam.desktop</code>

and find this line;

<code>Exec=/usr/games/steam %U</code>

and change it to;

<code>Exec=bash -c "LD_PRELOAD='/usr/$LIB/libstdc++.so.6' DISPLAY=:0 steam</code>



Monday, 17 June 2019

Some ffmpeg usage examples

Here are a few ffmpeg examples I have used on occasion:

Basic mkv to mp4 conversion
 ffmpeg -i original.mkv -vcodec copy -acodec copy new.mp4


Advanced mkv to mp4 conversion (copy multiple streams) 
 ffmpeg -i original.mkv -map 0:a -map 0:v -map 0:s -c:v copy -c:a copy -c:a copy -c:s mov_text new.mp4


Transcode to huffyuv + flac
 ffmpeg -i original.avi -f avi -c:v huffyuv -c:a flac new.avi


Copy video section (with audio)
 ffmpeg -i original.avi -c:v copy -c:a copy -ss 00:00:03.000 -t 00:00:26.000 new.part.avi


Reverse video
 ffmpeg -i original.avi -vf reverse -c:v huffyuv new.avi


Insert subtitles
 ffmpeg -i original.mp4 -i subtitles.srt -c:v copy -c:a copy -c:s mov_text new.mp4


Concat multiple files
 # cat part.list.txt
   file old.01.mp4
   file old.02.mp4
   file old.03.mp4

 ffmpeg -safe 0 -f concat -i part.list.txt -c:v copy -c:a copy new.mp4


Convert DVD without transcoding
 ffmpeg -i concat:VTS_07_1.VOB\|VTS_07_2.VOB\|VTS_07_3.VOB -map 0:v -map 0:a -c:v copy -c:a copy new.avi


Slow down video
 ffmpeg -i input.avi -filter:v "setpts=2.0*PTS" -c:v huffyuv output.avi


Speed up video
 ffmpeg -i input.avi -filter:v "setpts=0.5*PTS" -c:v huffyuv output.avi

Monday, 6 May 2019

Create and install an SSL certificate in Apache

Lets create a SSL encrypted website using apache.

Prequisites:
A working unsecured website on port 80
If your server is behind a firewall you will need to open/forward port 443
A publicly accessible FQDN is configured for the site.

Enable ssl on apache;
sudo a2ensite default-ssl.conf

Installing certbot;
sudo apt install certbot python-certbot-apache

Use certbot to create a free certificate;
sudo certbot --apache certonly

Follow the prompts, they are self explanatory.
Note: This will break if the certbot cannot resolve your domain name properly. I have used the --certonly flag to stop certbot from editing apache configs because I prefer to do it myself. Apparently if you drop that flag you can skip the next step.

Once you are done you should have a shiny new certificate in /etc/letsencrypt/live/www.example.com/

Now, if you did not allow certbot to modify your apache configs you will need tell apache to use your new certificate.

Edit the file that contains the virtualhost configuration for your web site. The virtualhost section should look like this;

        ServerName www.example.com
        ServerAdmin brettg@tuxnetworks.com
        DocumentRoot /var/www/html

        (...)


Modify it to look like this;

        ServerName www.example.com
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
  
        (...)



Restart your apache server and you should now be able to browse your site using https.

Note: If you want your site to work in both encrypted (SSL) mode as well as unsecured mode then when you are modifying the virtualhost config in apache copy that entire section to the end of the file and make the changes shown above in the new section

Tuesday, 19 March 2019

Cleaning up df output

I use df a lot on ubuntu. Unfortunately with advent of snap devices df output has become increasingly cluttered with various devices mounted by the system that I generally don' have an interest in seeing.

For example:

# /bin/df
Filesystem      1K-blocks       Used Available Use% Mounted on
udev              8121812          0   8121812   0% /dev
tmpfs             1630708       1888   1628820   1% /run
/dev/sda1        30627388   15252072  13796484  53% /
tmpfs             8153528      68012   8085516   1% /dev/shm
tmpfs                5120          4      5116   1% /run/lock
tmpfs             8153528          0   8153528   0% /sys/fs/cgroup
/dev/loop1          93184      93184         0 100% /snap/core/6405
/dev/loop2          93184      93184         0 100% /snap/core/6350
/dev/loop4          35456      35456         0 100% /snap/gtk-common-themes/818
/dev/loop7          35712      35712         0 100% /snap/gtk-common-themes/1122
/dev/sda2        76766240   26915652  45927952  37% /home
/dev/sdb       7814026584 7137072996 674941212  92% /mnt/library
/dev/sdc       3907018584 3436394816 467552000  89% /mnt/archive
tmpfs             1630704         16   1630688   1% /run/user/132
tmpfs             1630704         80   1630624   1% /run/user/1000
/dev/loop8          36224      36224         0 100% /snap/gtk-common-themes/1198
/dev/loop9          93312      93312         0 100% /snap/core/6531
/dev/loop0       48768594   48768594         0 100% /mnt/loop/Archive.TV.01
/dev/loop3       48628258   48628258         0 100% /mnt/loop/Archive.TV.02
/dev/loop5       48845728   48845728         0 100% /mnt/loop/Archive.TV.03


So that you don't have to visually hunt through that junk to see what you need add this to your users .bashrc file:

function df
{
  /bin/df "$@" | grep -v loop | grep -v tmpfs | grep -v udev
}

Now your df output just lists the actual mounted drives:

#df
Filesystem      1K-blocks       Used Available Use% Mounted on
/dev/sda1        30627388   15252080  13796476  53% /
/dev/sda2        76766240   26915652  45927952  37% /home
/dev/sdb       7814026584 7137072996 674941212  92% /mnt/library
/dev/sdc       3907018584 3436700752 467246064  89% /mnt/archive
/dev/loop0       48768594   48768594         0 100% /mnt/loop/Archive.TV.01
/dev/loop3       48628258   48628258         0 100% /mnt/loop/Archive.TV.02
/dev/loop5       48845728   48845728         0 100% /mnt/loop/Archive.TV.03

If you want see the full output use the full path /bin/df

autofs: keep devices permanently mounted

I have some ISO images which I use autofs to mount as loop devices.

For reasons that are not important I want them to stay mounted permanently.

I couldn't find any information online on how to do this so I poked around in the related autofs man pages.

I noticed that there is a time out option which is set by default to 600 seconds.

I wondered what would happen if I set that to 0 seconds so I tried it.

So far the devices in question have stayed mounted for 15 minutes

Here's how to do it:

/etc/auto.master
/mnt/loop /etc/auto.loops -t 0

/etc/auto.loops
* -fstype=iso9660,loop     :/store/ISO.archives/&.iso


The -t 0 is where we set the time out to 0 (infinite)
   
In case you are wondering the * at the beginning and the &.iso at the end of auto.loops will mount all of the iso files found in the /store/ISO.archives/ directory.

Friday, 2 November 2018

Monday, 3 September 2018

Steam controller doesn't work in Ubuntu 18.04

After upgrading or fresh install of Ubuntu 18.04 your previously working Steam controller will no longer be detected.

To fix this you must install a new package;

sudo apt install steam-devices