You are not logged in.

#1 2018-07-07 10:05:46

doomguy84
Member
Registered: 2018-05-09
Posts: 49

Conky - How to show Attached device with the filesystem within ?

Hello!
I already got an .sh script to show only the mounted filesystems of /dev, so it shows "root" and "boot" filesystem mounted.
and if I connect a device like a usb flash drive it correctly add a new line with the "label + filesystem + space" of the new one mounted.

I wanted to add the model name of these devices, and I found the command:

cat /sys/class/block/sda/device/model

but this command display only sda device name, if I use sd* it will display all the devices, including the multicard reader I don't need.

I just want to display something like this in my conky:

DEVICE NAME
MOUNTED POINT  - FILESYSTEM - USED SPACE / TOTAL SPACE

examples:

TOSHIBA HDD MODEL XXXXX
/ - btrfs - 100 GB / 200 GB
/boot - ext4 - 100 MB / 500 MB

KINGSTON USB FLASH DRIVE MODEL XXXXX
label - vfat - 10GB / 16 GB

is it possible??

Last edited by doomguy84 (2018-07-07 10:07:32)

Offline

#2 2018-07-07 12:14:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: Conky - How to show Attached device with the filesystem within ?

Sure it's possible - just write it that way:

prev=
findmnt -Dsn -o SOURCE,TARGET,USED,SIZE | sort | while read line; do
        cur=${line:5:3}
        [ "$cur" != "$prev" ] && echo && cat /sys/class/block/$cur/device/model
        echo "$line"
        prev=$cur
done

As is, this puts the device in the first column - this ensures the basename of the device will be at the same character positions for the substring extraction, but if you really wanted it in the other order you could use a regex to get the device name instead.  This also lacks your formating characters '-' and '/' but those could be added as desired.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB