Network Interface Name Detection in Conky

Once-off Conky config for network graphs

When one changes connection type (say, from ethernet to Wi-Fi), the interface name changes (e.g. eth0wlan1). To avoid changing Conky config file all the time, here’s a little Lua function for finding the network interface name.

function findInterface()
    local handle = io.popen('ip a | grep "state UP" | cut -d: -f2 | tr -d " "')
    local result = handle:read('*a'):gsub('\n$','')
    handle:close()
    return result
end
  1. ip a gives everything about connection info. Each entry looks like

     3: wlp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    
  2. Grep the “state UP” and extract the second field, using : as a delimiter. Trim off the spaces around.

    [Read More]
Conky  Lua 

CPU Temperature Display in Conky

Background

I’m using Conky for monitoring the system. After a system upgrade, the CPU temperatures were gone. Conky’s standard error showed the following.

Conky: can't open '/sys/class/hwmon/hwmon0/temp3_input': No such file or
directory please check your device or remove this var from Conky...

Source of message: https://bbs.archlinux.org/viewtopic.php?id=82231

An easy fix would be to adjust the following lines in .conkyrc according to the number N in /sys/class/hwmon/hwmonN containing the file temp3_input. (You may adjust the number 3 according to the number of CPU of your device.) The number of CPU can be found using grep -c ^processor /proc/cpuinfo.

[Read More]
Conky  CPU  Linux 

Animated GIF Screenshots on Ubuntu

Background

I’ve to take screenshots to demonstrate Conky’s visual output.

animated GIF screenshot taken by Byzanz

I’ve chosen Byzanz after reading this answer on Ask Ubuntu.

Peek is more user-friendly, but I prefer CLI’s precision. That’s feasible thanks to a comment mentioning xwininfo.

After typing xwininfo, click on the target window. Switching to adjacent workplace is possible.

$ xwininfo
xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1c0000a "Desktop"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 32
  Visual: 0x1a7
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1c00009 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

The --x and --y parameters below correspond to the absolute upper-left position of the window.

[Read More]