Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Example output:
- # /media/me/whatever
- # /media/me/whatever2
- #
- lsblkOutput=$(lsblk -J -o MOUNTPOINT | \
- jq -r '.blockdevices[] | select(.mountpoint != null) | .mountpoint | select(startswith("/media"))');
- nameToShow=""
- deviceMountpoint=""
- toConky=""
- if [[ "$lsblkOutput" == "" ]]
- then
- exit
- fi
- # To array
- readarray -t devices <<<"$lsblkOutput"
- for device in "${devices[@]}"
- do
- # Remove the path...
- nameToShow=${device##*/}
- # If the name has several words, only show the first one.
- nameToShow=${nameToShow%\ *}
- # In case the device has whitespaces in the name -> escape them
- device=$(printf "%q" "$device")
- toConky="$toConky\${template3 $nameToShow $device}\n"
- done
- printf '%b' "$toConky"
Add Comment
Please, Sign In to add comment