Foolproof way to put mounted partition status in Conky?

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
User avatar
houndstooth
Posts: 226
Joined: Sun Jul 17, 2022 9:41 am
Location: U.S.A.
Has thanked: 12 times
Been thanked: 17 times

Foolproof way to put mounted partition status in Conky?

Post by houndstooth »

JWM desktop partitions are one of its best features but not foolproof. Sometimes mount status icons are not reflecting their true state. mount cli always does. Other times there are issues with basic icon display & Puppy Event Manager interplay.

Is it possible to lightly put select mount status in Conky, sd* mmc* mtp*? I use 3 second Conky refresh intervals. I wouldn't want mount status checking to bog system resources but imagine a visual convenient alternative to mount.

User avatar
houndstooth
Posts: 226
Joined: Sun Jul 17, 2022 9:41 am
Location: U.S.A.
Has thanked: 12 times
Been thanked: 17 times

Re: Foolproof Mounted Partition Status

Post by houndstooth »

Even in XFCE in Puppy the alternatives I see at present are all or nothing desktop icons (ie, an inability to choose individual partitions), or Thunar greying unmounted partitions in a pane which is not as obvious as desktop partitions:

mounted partition guessing
mounted partition guessing
xfce-partition-thunar-pane-unmounted.jpg (3.14 KiB) Viewed 862 times

Is XFCE desktop partition mount status relatively foolproof? Yes, but they're not as controllable & Puppy XFCE usage is quaint.

Thunar View as Icons view in /mnt does not indicate mounted partitions like foolproof ROX-Filer which works normally in XFCE.

I could keep a ROX-Filer /mnt window open in a workspace but what else can we do?

geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

One thing I've developed over the past couple of years is a set of mount/umount scripts and run them from Xfe file manager.

Rather than create the mount points in the script, I've simply created a set of mount points in /mnt that are empty directories then the script runs the mount/umount command. This way I never somehow remove a directory while still mounted. Though that shouldn't happen if the umount command precedes the rm directory command in a script, I'm a little too paranoid to run it that way.

Below is xfe showing a directory full of mount scripts on the left, and on the right all the mount points. The green folders with dots are mounted and xfe never fails to display them correctly, as long the /mnt directory is refreshed.

This allows me to run the same system in Pups, KLVs, KLAs, using JWM, Xfce, Spectrwm, bspwm, awsome, hyprland, etc. So it's a universal method. A few of those window managers I mentioned don't show desktop icons, so I would have to be doing it from a file manager of some sort like Thunar, Pcmanfm, or Rox, but I prefer Xfe for it's consistenency and functionality. I only need that one file manager to get everything done. It even comes with Xfi and Xfw to display images and edit text.

Image

geo_c
Old School Hipster, and Such

User avatar
user1234
Posts: 413
Joined: Sat Feb 26, 2022 5:48 am
Location: Somewhere on earth
Has thanked: 154 times
Been thanked: 88 times

Re: Foolproof way to put mounted partition status in Conky?

Post by user1234 »

As far as I could understand your question, maybe you are trying to display mounted partitions in Conny window. This may help you then: viewtopic.php?t=10679.

Note that it can possibly overwrite your existing conkyrc. BTW, I can point out the required code to you, if you ask, :thumbup:

PuppyLinux 🐾 gives new life to old computers ✨

User avatar
houndstooth
Posts: 226
Joined: Sun Jul 17, 2022 9:41 am
Location: U.S.A.
Has thanked: 12 times
Been thanked: 17 times

Re: Foolproof way to put mounted partition status in Conky?

Post by houndstooth »

user1234 wrote: Fri Feb 23, 2024 3:37 am

As far as I could understand your question, maybe you are trying to display mounted partitions in Conny window. This may help you then: viewtopic.php?t=10679.

I see File Systems partitions updating with mount status. That could be useful reinforcement. I do not what motivated the new utility, imagine legacy Conky doing the same with the right code. If you want to share what it takes, by all means.

maybe a how to?

My original post as written was just about error-free partition mount indication, however that may be accomplished (not necessarily Conky).

User avatar
user1234
Posts: 413
Joined: Sat Feb 26, 2022 5:48 am
Location: Somewhere on earth
Has thanked: 154 times
Been thanked: 88 times

Re: Foolproof way to put mounted partition status in Conky?

Post by user1234 »

houndstooth wrote: Fri Feb 23, 2024 4:56 pm

I see File Systems partitions updating with mount status. That could be useful reinforcement. I do not what motivated the new utility, imagine legacy Conky doing the same with the right code. If you want to share what it takes, by all means.

maybe a how to?

If using that PET worked for you, that means your legacy conky can do this!

The trick is in the file named /root/.config/conky-gtk/show_mounts.lua. You can try reading it yourself.

Basically, that file contains a function that can be used to a generate the 'File Systems' section of conky. The function itself is called every 5 seconds after starting Conky from ~/.conkyrc.


That is not so interesting though! The actual part is this command which it calls to get only the mounted partitions:

Code: Select all

lsblk --raw --noheadings -o NAME,MOUNTPOINT -e7 | awk '$1~/[[:digit:]]/ && $2 != ""' | grep -v -i 'swap'

(Try running it in your terminal.)

You can use the same command in any of your scripts. Note that this command filters out all loop and swap devices. To include those, you can use the following:

Code: Select all

lsblk --raw --noheadings -o NAME,MOUNTPOINT | awk '$1~/[[:digit:]]/ && $2 != ""'

PuppyLinux 🐾 gives new life to old computers ✨

User avatar
MochiMoppel
Posts: 1145
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 376 times

Re: Foolproof way to put mounted partition status in Conky?

Post by MochiMoppel »

@Bassit Hound I'm not sure what you are asking for. Title and first post is about Conky, second post asks for alternatives?

If it is for Conky I can't help. I don't use it. However I also had problems to easily establish the status of mounted partitions since I don't use PuppyPin.
I therefore made a short script to pop up a gxmessage window with info about my currently mounted drive partitions. I use it with a keyboard shortcut. Tweak it as you like. Should work in all Puppies.

Code: Select all

#!/bin/sh
mounts=$(lsblk -rI8,11 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -
mounted_partitions.png
mounted_partitions.png (29.54 KiB) Viewed 686 times

Technical notes for our awk experts:
1) I wasn't able to let awk print only lines which contain a percentage value (=mounted partitions), hence the grep % workaround. Should be possible in awk. How?
2) The lsblk output escapes spaces like this: SAMSUNG\x20HD321KJ. In order to convert hex \x20 into a space I use GNU printf with a %b format specifier. Apparently I can't do this with awk's own printf implementation because %b is not supported. Any workaround in awk?

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

@MochiMoppel doesn't work for me (no output) and found that's it's because I have nvme partitions
This works: (-rI8,259)

Code: Select all

mounts=$(lsblk -rI8,259 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -

Only thing is that when mixed sda and nvme the columns are not aligned (with only sda mounted, it's ok):

2024-02-24_16-21-42.png
2024-02-24_16-21-42.png (42.06 KiB) Viewed 676 times
geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

fredx181 wrote: Sat Feb 24, 2024 3:28 pm

@MochiMoppel doesn't work for me (no output) and found that's it's because I have nvme partitions
This works: (-rI8,259)

Code: Select all

mounts=$(lsblk -rI8,259 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -

Only thing is that when mixed sda and nvme the columns are not aligned (with only sda mounted, it's ok):
2024-02-24_16-21-42.png

@fredx181 I've been working with it and it doesn't show mmcblk0p1. Do you know how to add that?

geo_c
Old School Hipster, and Such

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

@geo_c I can't test that atm, post the output of lsblk with your SD card connected (assuming it's SD card).

geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

fredx181 wrote: Sat Feb 24, 2024 3:47 pm

@geo_c I can't test that atm, post the output of lsblk with your SD card connected (assuming it's SD card).

Here it is:

Code: Select all

bash-5.2# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0  64.3M  0 loop /mnt/layers/01
loop1         7:1    0   1.3G  0 loop /mnt/layers/07
loop2         7:2    0   260K  0 loop /mnt/layers/15
loop3         7:3    0    32M  0 loop /mnt/layers/00firmware_modules
sda           8:0    0 223.6G  0 disk 
`-sda1        8:1    0 223.6G  0 part /mnt/layers/merged/mnt/sda1
                                      /mnt/sda1
sdb           8:16   1 465.8G  0 disk 
|-sdb1        8:17   1   193M  0 part 
|-sdb2        8:18   1   457G  0 part 
`-sdb3        8:19   1   8.5G  0 part 
sr0          11:0    1  1024M  0 rom  
nbd0 43:0 0 0B 0 disk nbd1 43:32 0 0B 0 disk nbd2 43:64 0 0B 0 disk nbd3 43:96 0 0B 0 disk nbd4 43:128 0 0B 0 disk nbd5 43:160 0 0B 0 disk nbd6 43:192 0 0B 0 disk nbd7 43:224 0 0B 0 disk mmcblk0 179:0 0 239.1G 0 disk `-mmcblk0p1 179:1 0 239.1G 0 part nbd8 43:256 0 0B 0 disk nbd9 43:288 0 0B 0 disk nbd10 43:320 0 0B 0 disk nbd11 43:352 0 0B 0 disk nbd12 43:384 0 0B 0 disk nbd13 43:416 0 0B 0 disk nbd14 43:448 0 0B 0 disk nbd15 43:480 0 0B 0 disk bash-5.2#

geo_c
Old School Hipster, and Such

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

As the number of mmcblk0p1 is 179, perhaps this (mmcblk0p1 needs to be mounted to show in output):
(edit: added 43 too) (-rI8,43,179,259) but frankly I don't know about nbd .

Code: Select all

mounts=$(lsblk -rI8,43,179,259 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -
geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

fredx181 wrote: Sat Feb 24, 2024 4:13 pm

As the number of mmcblk0p1 is 179, perhaps this (mmcblk0p1 needs to be mounted to show in output):
(edit: added 43 too) (-rI8,43,179,259)

Code: Select all

mounts=$(lsblk -rI8,43,179,259 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -

Yes I think I mounted it first. @MochiMoppel's script doesn't show unmounted partitions, just the mounted ones. And it's nice because I put the script in an executable file /root/my-applications/bin/mntd and tacked the command on to my mount scripts that I store in a directory in /mnt. This is handy in KLV-spectr, as I have gxmessage windows float and then when I run a mount script from Xfe, mochi's script pops a window and confirms the mounted drives.

Like this:

Code: Select all

#!/bin/sh

mount /dev/sdb2 /mnt/sdb2
/mnt/vmnt/mntd

Image

Last edited by geo_c on Sat Feb 24, 2024 4:46 pm, edited 1 time in total.

geo_c
Old School Hipster, and Such

geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

fredx181 wrote: Sat Feb 24, 2024 4:13 pm

As the number of mmcblk0p1 is 179, perhaps this (mmcblk0p1 needs to be mounted to show in output):
(edit: added 43 too) (-rI8,43,179,259) but frankly I don't know about nbd .

Code: Select all

mounts=$(lsblk -rI8,43,179,259 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%4s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -

That doesn't seem to get the mmcblk0p1 though, probably because I'm not in puppy, and instead I'm running these in KLV-spectrwm.


CORRECTION Actually it does show up. I tried chaning 179 to 179:1 and the script didn't display anything, then I changed it back and it worked. Not sure what's going on there.

Maybe the drive didn't show because the first time it ran from my mount script, and the second time I just ran your script by itself.

NO sorry this script is working perfectly, I had two scripts and ran the wrong one.

This is working great!

THANKS @fredx181 , I'll probably have to run lsblk on different machines and adjust the script I imagine.

geo_c
Old School Hipster, and Such

User avatar
houndstooth
Posts: 226
Joined: Sun Jul 17, 2022 9:41 am
Location: U.S.A.
Has thanked: 12 times
Been thanked: 17 times

Re: Foolproof way to put mounted partition status in Conky?

Post by houndstooth »

Coder gui looks good, but to keep that box open & updated in real time?

I have a couple different scripts. One opens a urxvt window & this works staying in the same terminal:

Code: Select all

#!/bin/sh
mount | grep -i -e mtp -e sd -e mmc
echo ''
User avatar
MochiMoppel
Posts: 1145
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 376 times

Re: Foolproof way to put mounted partition status in Conky?

Post by MochiMoppel »

fredx181 wrote: Sat Feb 24, 2024 3:28 pm

@MochiMoppel doesn't work for me (no output) and found that's it's because I have nvme partitions
This works: (-rI8,259)

Try lsblk -re7 . This approach by @user1234 to exclude only the No.7 loops might work better for you and @geo_c and the rest of the world ;)

Only thing is that when mixed sda and nvme the columns are not aligned (with only sda mounted, it's ok):
2024-02-24_16-21-42.png

Increase leading space padding by changing printf '%4s to a more generous printf '%10s

geo_c
Posts: 2608
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1876 times
Been thanked: 744 times

Re: Foolproof way to put mounted partition status in Conky?

Post by geo_c »

MochiMoppel wrote: Sun Feb 25, 2024 1:23 am
fredx181 wrote: Sat Feb 24, 2024 3:28 pm

@MochiMoppel doesn't work for me (no output) and found that's it's because I have nvme partitions
This works: (-rI8,259)

Try lsblk -re7 . This approach by @user1234 to exclude only the No.7 loops might work better for you and @geo_c and the rest of the world ;)

Only thing is that when mixed sda and nvme the columns are not aligned (with only sda mounted, it's ok):
2024-02-24_16-21-42.png

Increase leading space padding by changing printf '%4s to a more generous printf '%10s

Yes, this does show the sd card mmblk0p1, thanks!

geo_c
Old School Hipster, and Such

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

MochiMoppel wrote: Sun Feb 25, 2024 1:23 am
fredx181 wrote: Sat Feb 24, 2024 3:28 pm

@MochiMoppel doesn't work for me (no output) and found that's it's because I have nvme partitions
This works: (-rI8,259)

Try lsblk -re7 . This approach by @user1234 to exclude only the No.7 loops might work better for you and @geo_c and the rest of the world ;)

Only thing is that when mixed sda and nvme the columns are not aligned (with only sda mounted, it's ok):
2024-02-24_16-21-42.png

Increase leading space padding by changing printf '%4s to a more generous printf '%10s

Thanks, works well.

Code: Select all

mounts=$(lsblk -re7 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%')
printf '%10s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -
2024-02-25_10-30-33.png
2024-02-25_10-30-33.png (45.1 KiB) Viewed 520 times
User avatar
MochiMoppel
Posts: 1145
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 376 times

Re: Foolproof way to put mounted partition status in Conky?

Post by MochiMoppel »

fredx181 wrote: Sun Feb 25, 2024 9:32 am

Thanks, works well.

You're welcome, but I hate to tell you that it does not work well. At least not when you need a foolproof solution.

Here is a possible scenario: You have a USB stick, let's say sdc1, plugged and mounted. PuppyPin shows the icon with the 'mounted' marker.
Now you unplug the stick.
What happens on the desktop? The icon disappears. Makes sense because there is no stick anymore. However the mount isn't gone. The - now dysfunctional - mountpoint /mnt/sdc1 is still there and weird things happen when you try to access it. Puppy should have warned you when it removed the icon, but it's not that clever (or it doesn't imagine that anyone would do such thing). When you reattach the USB stick it will be named sdd1 because sdc1 is still mounted and therefore the name already taken.

Anyway, my previous script relies on lsblk which lists only devices that are present .... and the sdc1 stick is gone! This means that the dialog wouldn't list it and would give wrong information about mounted partitions.

I've therefore modified my script. It now reconciles the output of lsblk with information from /proc/mounts. Any devices listed in /proc/mounts that are not present in lsblk must be what I call 'orphans' (don't know if there is an official term for mounts which "lost" their device). For simplicity I don't verify the mountpoints of these orphans. Most likely they are in the /mnt folder (for 100% accuracy it could be checked with /proc/self/mountinfo). Unmounting should be done manually by the user. In principle could also be done automatically by the script but let's keep it simple.

Here is what I came up with. Seems to work:

Code: Select all

mounts=$(
  {
    lsblk -re7 -no NAME,MODEL,FSSIZE,FSUSE%,MOUNTPOINT | awk -F[\ ] '$2~/./?v=$2:$2=v' | grep '%'
    awk '/^\/dev\// && !/^\/dev\/loop/ {print substr($1, 6) " ORPHAN!\\x20UNMOUNT! - - /mnt/"substr($1, 6)"?"}' /proc/mounts
  } | sort -uk1,1
)
printf '%10s %20.20b %8s %4s %s\n' DEV MODEL SIZE USED MOUNTPOINT $mounts | gxmessage -title Mounted\ partitions -c -fn mono -de okay -file -
orphans.png
orphans.png (81.88 KiB) Viewed 489 times

Note the funny dates of the mountpoints :lol: Could be another bug...

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

Note the funny dates of the mountpoints :lol: Could be another bug...

Or you broke the record: "longest mounted USB", 54 years ! :lol:

User avatar
user1234
Posts: 413
Joined: Sat Feb 26, 2022 5:48 am
Location: Somewhere on earth
Has thanked: 154 times
Been thanked: 88 times

Re: Foolproof way to put mounted partition status in Conky?

Post by user1234 »

That seems to be the POSIX epoch time!

So, that has been mounted since time (in computing) was invented :lol:!

PuppyLinux 🐾 gives new life to old computers ✨

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

This is clear proof that MochiMoppel was the inventor of USB ! Already in 1970 ! :D

User avatar
MochiMoppel
Posts: 1145
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 376 times

Re: Foolproof way to put mounted partition status in Conky?

Post by MochiMoppel »

fredx181 wrote: Mon Feb 26, 2024 10:51 am

Or you broke the record: "longest mounted USB", 54 years ! :lol:

Oh, if your location is Holland then you can easily beat me by 8 hours.
Check your mounted and FAT32 formatted USB stick or SD card ;)

User avatar
fredx181
Posts: 2680
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 295 times
Been thanked: 1056 times
Contact:

Re: Foolproof way to put mounted partition status in Conky?

Post by fredx181 »

MochiMoppel wrote: Tue Feb 27, 2024 4:21 am
fredx181 wrote: Mon Feb 26, 2024 10:51 am

Or you broke the record: "longest mounted USB", 54 years ! :lol:

Oh, if your location is Holland then you can easily beat me by 8 hours.
Check your mounted and FAT32 formatted USB stick or SD card ;)

Yesss... !

Screenshot(4).png
Screenshot(4).png (11.32 KiB) Viewed 393 times
User avatar
houndstooth
Posts: 226
Joined: Sun Jul 17, 2022 9:41 am
Location: U.S.A.
Has thanked: 12 times
Been thanked: 17 times

Re: Foolproof way to put mounted partition status in Conky?

Post by houndstooth »

I have been tweaking Conky a little for color, placement & basic formatting.

User1234's post begs focus as the possible solution. It appears to handle the gist:

If JWM desktop partitions are useful but not fullproof, is Conky the utility to address mount status doubt?

Post Reply

Return to “Users”