24. March 2017

How to start Wireshark on openSUSE

The simple way how to start Wireshark on Linux is to type:

wireshark

If you run this command as a normal user you won’t be able to capture packets. In order to dump packets, you need to execute it as root. This must be done in a specific way. If try just sudo you’ll end up with interesting errors like:

Attempt #1

$ sudo su
# wireshark
QXcbConnection: Could not connect to display 
Aborted (core dumped)

Attempt #2

$ sudo wireshark
QXcbConnection: Could not connect to display 
[1]    8836 abort      sudo wireshark

The proper way how to start Wireshark is by gtk-su:

xdg-su -c wireshark

13. March 2017

How to switch tabs in Konsole

Konsole has support for tabs like other terminal emulators. The question is how to switch between tabs using a keyboard.

Default keyboard shortcut is Shift + Left/Right Arrow.

If you’re used to other keyboard shortcuts like Ctrl + PgUp/PgDn which are common in Google Chrome then you can add new shortcuts easily.

Open menu Settings, select Configure Shortcuts…

Type word tab into Search field.

Find item Next tab. Click column Alternate. Click button with title None. Now you can define a keyboard shortcut. Press Ctrl + PgUp.

Find item Previous tab. Click column Alternate and button with title None. Press Ctrl + PgDown. Click OK to confirm your configuration.

Now you can enjoy new configuration. If you like this tip or you’d like some other hint about Linux let me know in the comments section bellow.

8. March 2017

How to enable line numbers in KWrite

The text editor KWrite has support for line numbers. This feature is disabled by default. You can enable it by few clicks.

From menu Settings select Configure Editor…

Navigate to Appearance. Select Borders tab, click Show line numbers and click OK.

Here you can see KWrite with enabled line numbers:

20. February 2017

How to send command from Python via MQTT to RGB LED connected to ESP8266

I’ve described how to send server load as a number to MQTT in the previous article. The number could be then translated via Node-RED to command for LampESP with RGB LED. The result is simple. LED indicates server load by displaying different colors.

The other option is to deliver color command directly from the server using Python.

Just install paho-mqtt:

pip install paho-mqtt

Here is small snippet of Python code (publish_server_load.py):

#!/usr/bin/env python3

import paho.mqtt.publish as publish
import os

color = 'red'
load = os.getloadavg()[0]
if load < 0.7:
    color = 'black'
elif load < 1.5:
    color = 'blue'
elif load < 3:
    color = 'green'
elif load < 7:
    color = 'orange'

publish.single('/server/monitoring/command', color, hostname='iot.sinusgear.com')

ESP should listen to /server/monitoring. Code of LampESP 0.3 is available at GitHub.

Put this code into crontab

* * * * * /usr/local/bin/publish_server_load.py

If you’re using virtualenv the command should be:

* * * * * /opt/my-python-env3/bin/python /usr/local/bin/publish_server_load.py

18. February 2017

How to configure Two-Finger Scrolling in openSUSE KDE to behave the same way like Apple MacBook

Two-Finger scrolling in openSUSE – KDE has same default configuration like Windows 10 on Lenovo. This configuration came from old days when users were using only mouse to navigate on the web. When using touchpad it’s natural to expect that it would behave similarly to a tablet or Apple MacBook. Apple made the switch in the direction some time ago to make it more natural. For some reasons developers keep the old style on Linux and even on Windows. Luckily it is possible to change the configuration very easily.

Go to System Settings and click Hardware – Input Devices

Select Touchpad from left pane, Scrolling from the tabs and check option Reverse scrolling – Vertical. Then click Apply.