Category: Linux

Steps to (maybe) fix hardware graphics acceleration

Command to verify hardware acceleration (only works inside xorg session):

Positive example:

$ glxinfo | grep render

direct rendering: Yes
    GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer, 
    GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer, 
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2) 
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth, 
    GL_NV_conditional_render, GL_NV_depth_clamp, GL_NV_packed_depth_stencil, 
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth, 
    GL_MESA_window_pos, GL_NV_blend_square, GL_NV_conditional_render, 
    GL_OES_element_index_uint, GL_OES_fbo_render_mipmap,

Negative example (llvmpipe (LLVM 6.0, 256 bits) means it’s using software rendering):

$ glxinfo | grep render

direct rendering: Yes
    GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
    GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: llvmpipe (LLVM 6.0, 256 bits)
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth,
    GL_NV_conditional_render, GL_NV_depth_clamp, GL_NV_packed_depth_stencil,
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth,
    GL_NV_blend_square, GL_NV_conditional_render, GL_NV_depth_clamp,
    GL_OES_element_index_uint, GL_OES_fbo_render_mipmap,

Session type:

$ loginctl show-session c2 -p Type
Type=x11

Make sure these are installed:

linux-image-extra
libegl1-mesa
libgl1-mesa-dri
libgl1-mesa-dri
libgl1-mesa-glx
libglapi-mesa
libgles2-mesa
libglu1-mesa
libwayland-egl1-mesa
mesa-utils
mesa-vdpau-drivers

Kernel versions working:

4.10.0-33-generic
4.15.0-15-generic

Linux specific packages:

dpkg -l | awk '{ print $2 }' | grep ^linux
linux-base
linux-firmware
linux-headers-4.15.0-15
linux-headers-4.15.0-15-generic
linux-image-4.15.0-15-generic
linux-image-extra-4.15.0-15-generic
linux-libc-dev:amd64
linux-sound-base
apt install linux-headers-generic linux-generic

Using Alexa (Amazon Echo / Echo Dot) with 433 Mhz remote power sockets

Requirements

Hardware

  • 433 Mhz remotely-controlled power sockets
    I am using some 10 year old “no name” power sockets. A lot of people recommend Brennenstuhl, but almost any model should just work fine.
    I also use some switches that can be hidden behind your existing wall switches (like the ITDM-250 or ITL-320). Please do not buy these hidden switches if you do not know how to install them, as you need to mess with high voltages.
  • A 433Mhz sender like one of these: https://www.amazon.de/dp/B00OLI93IC/ref=cm_sw_em_r_mt_dp_JUY-ybZXRXYXK
  • An Arduino Nano and an USB cable
  • A Raspberry Pi
    The model of the Pi should not really matter. I am using the Raspberry Pi 1 Model B. Any Raspberry Pi that can be attached to your network while still providing 1 free USB port works fine. A newer Raspberry Pi will speed up the installation of Pimatic which needs to be compiled on the Pi and can take hours.
  • Some tea / coffee and something else to do while pimatic compiles.
  • Of course an Amazon Echo / Echo Dot

Software

  • an updated version of Raspbian for the Raspberry Pi
  • Pimatic
    • Plugins
      • echo
      • homeduino
  • the Arduino IDE to flash the Arduino Nano with homeduino

Demo

Getting started

I will not cover

As there are (far too) many guides on the following points, I will not cover these:

If you follow the guides linked above, you will get some working enviroment.

What belongs where

If you followed all the guides or already have some working enviroment, the last thing to do is to put everything together.

-------------
| Raspberry |-------- Network
|     Pi    |--------
-------------       |
                    |
                -----------
                | Arduino |--------- 433 Mhz Sender
                -----------

It’s pretty simple and pretty straight forward in my opionion.

My Arduino 433MHz sender looks like this:

 

Ein Beitrag geteilt von Jan (@superseriouscat) am

Configuration of pimatic

This is the default configuration:

{
  "//": "Please only change this file when pimatic is NOT running, otherwise pimatic will overwrite your changes.",
  "settings": {
    "httpServer": {
      "enabled": true,
      "port": 80
    },
    "database": {
    }
  },
  "plugins": [
    {
      "plugin": "cron"
    },
    {
      "plugin": "mobile-frontend"
    }
  ],
  "devices": [

  ],
  "rules": [

  ],
  "pages": [
    {
      "id": "favourite",
      "name": "Favourites",
      "devices": []
    }
  ],
  "groups": [

  ],
  "users": [
    {
      "username": "admin",
      "password": "",
      "role": "admin"
    }
  ],
  "roles": [
    {
      "name": "admin",
      "permissions": {
        "pages": "write",
        "rules": "write",
        "variables": "write",
        "messages": "write",
        "events": "write",
        "devices": "write",
        "groups": "write",
        "plugins": "write",
        "updates": "write",
        "database": "write",
        "config": "write",
        "controlDevices": true,
        "restart": true
      }
    }
  ]
}

To enable the Alexa Echo and homeduino integration just add the following lines to the plugin section:

"plugins": [
  {
    "plugin": "cron"
  },
  {
    "plugin": "mobile-frontend"
  },
  {
    "plugin": "homeduino",
    "driver": "serialport",
    "driverOptions": {
      "serialDevice": "/dev/ttyUSB0",
      "baudrate": 115200
    },
    "receiverPin": 0,
    "transmitterPin": 4,
    "rfrepeats": 7,
    "active": true,
    "debug": false
  },
  {
    "plugin": "echo",
  },
],

Do not forget to add the correct serial device, receiverPinbaudrate and transmitterPin.

You should be pretty much done and ready to start pimatic.

Do not forget that pimatic takes an insane amount of time at the first start (due to npm downloading and compiling binaries).

Settings up devices

The device setup depends on your device and the device type. For me the switches were supported by Homeduino and so I used the HomeduinoRFSwitch class. You may need to use a different class or device type.

Example of the configuration of one 433MHz switch:

{
      "protocols": [
        {
          "name": "switch4",
          "options": {
            "unit": 1,
            "id": 2
          },
          "send": true
        }
      ],
      "id": "licht",
      "name": "Licht",
      "class": "HomeduinoRFSwitch",
      "echo": {
        "name": "Licht",
        "additionalNames": [],
        "active": true
      }
    }

This basically adds the switch to pimatic and tells the Echo plugin about its existence. You can do this for each switch manually even if the webinterface does not support it.

Pairing Alexa with pimatic

To pair Alexa and pimatic just go to the devices page on the webinterface:

This will enable pairing mode in pimatic:


If you did everything right, new devices will show up in your Alexa app:

Here you go: You can now control your devices using Alexa without any external API.

New tool: Outgoing port checker

Yesterday I created a new tool, that let’s you check the firewall configuration of your network and other networks for outgoing open ports.

Many public networks do not allow the full port range to be used and figuring out, which ports can be used and which cannot be used, may give you a hard time. This tool allows you to check this directly in your browser.

The host openports.jan.philippi.name listens on all ports for incoming HTTP/s connections and replies on all ports. Clear text HTTP connections will receive a “301 Permanently Moved” HTTP status code. HTTPs connections will receive a “200 OK” status code.

You can find this cool new tool here: https://openports.jan.philippi.name/

Known limitations:

  • A lot of ports are blocked by your browser. Currently it seems like there is no way around it, but you can use different tools like curl, wget, etc. to check this.

Automatic fix for Spotify scaling bad on HiDPI screens on Arch Linux using yaourt, hooks and pacman

Spotify scales pretty bad on HiDPI screens (like the XPS 13 with 4k screen). All the text is small and barely readable. Tangram mentioned a fix for this issue, but everytime you update Spotify from the AUR it will update and break the .desktop file.

To make pacman fix this automatically there is a feature called Hooks. In the following we will create a hook to replace the .desktop file, which is the starter for spotify on a lot of window managers.

First we need a small script that will rewrite this file:

#!/bin/bash

echo '[Desktop Entry]
Name=Spotify
GenericName=Music Player
Comment=Spotify streaming music client
Icon=spotify-client
Exec=spotify --force-device-scale-factor=2.3 %U
TryExec=spotify
Terminal=false
Type=Application
Categories=Audio;Music;Player;AudioVideo;
MimeType=x-scheme-handler/spotify;' > /usr/share/applications/spotify.desktop

Do not forget to set your scaling factor in line 8 to a reasonable value. 2.3 works fine for the XPS13 with a 4k display.

You need to save this file to

/usr/local/sbin/fix-scaling-spotify.sh

Then we will create a hook, that will run on “Upgrade” and “Install”.

[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = spotify

[Action]
Depends = spotify
When = PostTransaction
Exec = /usr/local/sbin/fix-scaling-spotify.sh

Save this hook to

/etc/pacman.d/hooks/

If this directory does not exist, create it using

mkdir -p /etc/pacman.d/hooks
yaourt -S spotify

==> Lade PKGBUILD von spotify aus dem AUR herunter...
x .SRCINFO
x .gitignore
x LICENSE
x PKGBUILD
x spotify
x spotify.protocol
annata83 commented on 2017-05-27 00:06			 
Hi, I just starting out with arch.. don't understand much of how  building goes yet, I downloaded the snapshot and execute it with makepkg -si.. now i get this:
usr/share/spotify/spotify: /usr/lib/libssl.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /usr/share/spotify/spotify)
/usr/share/spotify/spotify: /usr/lib/libcrypto.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /usr/share/spotify/spotify)
/usr/share/spotify/spotify: /usr/lib/libcurl.so.3: no version information available (required by /usr/share/spotify/spotify)
...............................
I also run yaourt -S libopenssl-1.0-compat libcurl-openssl-1.0 spotify after adding the keys but same thing. What is this and how can I fix it?

By the way trying to check for openssl 1.0 i get this:
openssl-1.0-compat and libopenssl-1.0-compat are in conflict

d4n3sh commented on 2017-05-27 01:43			 
Confirmed, ssl was officially reverted. #sudo pacman -Syu today and the problem is fixed.

NicoHood commented on 2017-05-27 08:57			 
@ayoung The terms of use forbid to redistribute Spotify in our official repositories. If you package it on your own, thats a different procedure.

I've contacted spotify and was forwarded to the boss of the desktop app and the main 2 linux devs. However I got no response back after that.

If you guys want to have spotify in our official repository I suggest opening a thread in their forum. People need to upvote this and then we can possibly work closer with spotify. I am willing to package spotify for [community].

Lenovsky commented on 2017-05-28 08:59			 
@NicoHood 
Hey, since you know the problem better than us, could you start such a thread and link it here or/and  somewhere? It would be great 😉

NicoHood commented on 2017-05-28 14:45			 
@Lenovsky There you go. Please upvote this topic if you wish to have spotify in the official ArchLinux [community] repository.

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Redistribute-Spotify-on-Linux-Distributions/m-p/1695334#M188735

spotify 1.0.55.487-2  (2017-05-26 02:14)
(Nicht unterstütztes Paket: Potenziell gefährlich!)
==> PKGBUILD bearbeiten? [J/n] („A“ zum Abbrechen)
==> ----------------------------------------------
==> n

==> Von spotify benötigt:
 - alsa-lib>=1.0.14 (bereits installiert)
 - gconf (bereits installiert)
 - gtk2 (bereits installiert)
 - glib2 (bereits installiert)
 - nss (bereits installiert)
 - libsystemd (bereits installiert)
 - libxtst (bereits installiert)
 - libx11 (bereits installiert)
 - libxss (bereits installiert)
 - openssl-1.0 (bereits installiert)
 - libcurl-compat (bereits installiert)
 - desktop-file-utils (bereits installiert)
 - rtmpdump (bereits installiert)


==> Mit dem Erstellen von spotify fortfahren?[J/n]
==> ----------------------------------------------
==> 

==> Erstelle und installiere Paket
==> Erstelle Paket: spotify 1.0.55.487-2 (Di 30. Mai 08:44:14 CEST 2017)
==> Prüfe Laufzeit-Abhängigkeiten...
==> Prüfe Buildtime-Abhängigkeiten...
==> Empfange Quellen...
  -> spotify gefunden
  -> spotify.protocol gefunden
  -> LICENSE gefunden
  -> Lade spotify-client_1.0.55.487.g256699aa-16_amd64.deb herunter...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 86.8M  100 86.8M    0     0  2557k      0  0:00:34  0:00:34 --:--:-- 6809k
==> Überprüfe source Dateien mit sha256sums...
    spotify ... Durchgelaufen
    spotify.protocol ... Durchgelaufen
    LICENSE ... Durchgelaufen
==> Überprüfe source_x86_64 Dateien mit sha256sums...
    spotify-client_1.0.55.487.g256699aa-16_amd64.deb ... Durchgelaufen
==> Entpacke Quellen...
  -> Entpacke spotify-client_1.0.55.487.g256699aa-16_amd64.deb mit bsdtar
==> Betrete fakeroot Umgebung...
==> Beginne package()...
==> Säubere Installation...
  -> Entferne libtool Dateien...
  -> Bereinige ungewollte Dateien...
  -> Entferne statische Bibliotheken...
  -> Komprimiere Man-Pages und Info-Seiten...
==> Prüfe auf Paketierungsprobleme...
==> Erstelle Paket "spotify"...
  -> Erstelle .PKGINFO Datei...
  -> Erstelle .BUILDINFO Datei...
  -> Erstelle .MTREE-Datei...
  -> Komprimiere Paket... 
==> Verlasse fakeroot Umgebung.
==> Beendete Erstellung: spotify 1.0.55.487-2 (Di 30. Mai 08:46:34 CEST 2017)
==> Räume auf...

==> Mit der Installation von spotify fortfahren? [J/n]
==> [I]nhalte des Pakets ansehen [P]aket mit Namcap überprüfen
==> ----------------------------------------------------------
==> J

[sudo] Passwort für jan: 
Lade Pakete...
Löse Abhängigkeiten auf...
Suche nach in Konflikt stehenden Paketen...

Pakete (1) spotify-1.0.55.487-2

Gesamtgröße der installierten Pakete:  203,45 MiB

:: Installation fortsetzen? [J/n] 
(1/1) Prüfe Schlüssel im Schlüsselring               [###########################] 100%
(1/1) Überprüfe Paket-Integrität                     [###########################] 100%
(1/1) Lade Paket-Dateien                             [###########################] 100%
(1/1) Prüfe auf Dateikonflikte                       [###########################] 100%
(1/1) Überprüfe verfügbaren Festplattenspeicher      [###########################] 100%
:: Verarbeite Paketänderungen...
(1/1) Installiere spotify                            [###########################] 100%
Optionale Abhängigkeiten für spotify
    ffmpeg0.10: Adds support for playback of local files
    zenity: Adds support for importing local files [Installiert]
:: Starte post-transaction hooks...
(1/4) Updating icon theme caches...
(2/4) spotify-fix-scaling-PostInstall.hook
(3/4) Arming ConditionNeedsUpdate...
(4/4) Updating the desktop file MIME type cache...

That’s it. Just upgrade spotify using yaourt and pacman will run the hook.

Fixing chown issues on Proxmox with OVH / SoYouStart NFS backup space

Update: I have merged this fix and it is applied to all Proxmox Installations at OVH.


If you have ever tried using the OVH / SoYouStart backup space, might have had some issues with doing backups. The reason behind this is that Proxmox tries to use the backup storage as temporary directory, but setting acls and xattr for the files will fail as giving files root as user or group is not allowed for security reasons.

INFO: starting first sync /proc/12420/root// to /mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/." failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/bzcmp" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/bzegrep" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/bzfgrep" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/bzless" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/dnsdomainname" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/domainname" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/lessfile" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/lsmod" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/mt" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/nc" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/netcat" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/nisdomainname" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/pidof" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/ping4" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/ping6" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/rbash" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/rnano" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/sh" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/sh.distrib" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/systemd" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/bin/ypdomainname" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/boot" failed: Operation not permitted (1)
INFO: rsync: chown "/mnt/pve/nfsback/dump/vzdump-lxc-101-2017_05_20-10_02_55.tmp/dev" failed: Operation not permitted (1)

The fix is as simple as reading the first line of the log:

temporary directory is on NFS, disabling xattr and acl support, consider configuring a local tmpdir via /etc/vzdump.conf

To fix this, simply create a directory for the temporary files. E.g.

mkdir /var/lib/vz/temp_back_dir

then fix the /etc/vzdump.conf:

# vzdump default settings

tmpdir: /var/lib/vz/temp_back_dir
#dumpdir: DIR
#storage: STORAGE_ID
#mode: snapshot|suspend|stop
#bwlimit: KBPS
#ionice: PRI
#lockwait: MINUTES
#stopwait: MINUTES
#size: MB
#stdexcludes: BOOLEAN
#mailto: ADDRESSLIST
#maxfiles: N
#script: FILENAME
#exclude-path: PATHLIST
#pigz: N:

Enjoy backups to your OVH / SoYouStart backup storage.

Fixing backlight control & controls of (some) Sony VAIO laptops

In order to be able to use the hotkeys and to change the backlight brightness at all, it takes some further steps after installing Ubuntu / Linux Mint / any other compatible linux distribution.

First you need to install nvidia-current from the repository (for me, it installed nvidia-graphics-drivers-304).

sudo apt-get update
sudo apt-get install nvidia-current

I rebooted my machine after installation to enable the driver. This might not be necessary and could also be done when all steps are completed.

Next we need to create a new xorg.conf file. Nvidia gives us a tool for this:

sudo nvidia-xconfig

This will create a new config file in /etc/X11/. Now open the new config (/etc/X11/xorg.conf) file with your favourite text editor.

Before:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

After:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection

Add the additional line and save the config file.

After these steps you need to reboot your machine. If you already did this after installing the drivers, it should be enough to restart X.

 

Sources:

http://askubuntu.com/a/326506