Na jednym forum zaproponowano mi rozwiązanie pt. "stłucz pan termometr nie będziesz pan miał gorączki":
Kod: Zaznacz cały
conky -c ~/Pulpit/test > /dev/null 2>&1

Kod: Zaznacz cały
conky -c ~/Pulpit/test > /dev/null 2>&1
Kod: Zaznacz cały
${if_mounted /media/disk}${fs_bar /media/disk}$endif
Kod: Zaznacz cały
#!/bin/bash
declare -a _index
declare -a _mount_point
_index=100
for x in $(hal-find-by-property --key access_control.type --string removable-block)
do
_mp=; _mp=$(hal-device "$x" |grep "volume\.mount_point" |cut -d\' -f2)
if [ "$_mp" ];
then
_index=$[--_index]; _array_index[$_index]=$_index
_mount_point[$_index]="$_mp"
_device=$(hal-device "$x" |grep "access_control\.file" |cut -d\' -f2)
_udi=$(hal-device "$x" |grep "block\.storage_device" |cut -d\' -f2)
# _dvendor=$(hal-device "$_udi" |grep "info\.vendor" |cut -d\' -f2)
_dproduct=$(hal-device "$_udi" |grep "info\.product" |cut -d\' -f2)
# if [ "$_dvendor" ]; then _name[$_index]="${_name[$_index]} $_dvendor"; fi
if [ "$_dproduct" ]; then _name[$_index]="${_name[$_index]} $_dproduct"
else _name[$_index]="${_name[$_index]} $(hal-device $x |grep "info\.product" |cut -d\' -f2)"; fi
_name[$_index]="${_name[$_index]/\ }"
y=$(df -h |grep $(echo "$_device"))
if [ "$y" ]
then
set $y
_device[$_index]="$1"
_space_used[$_index]="$3"
_space_free[$_index]="$4"
_percent_used[$_index]="$5"
_space_available[$_index]="$2"
fi
fi
done
for x in "${_array_index[@]}"
do
echo
echo -e "\${font :size=8:weight=bold}${_name[$x]}:"
echo -e "\${font :size=8:weight=bold}\${tab 16}device\${tab 54}= ${_device[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}mount point\${tab 54}= ${_mount_point[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space used\${tab 54}= ${_space_used[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space free\${tab 54}= ${_space_free[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}percent used\${tab 54}= ${_percent_used[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space available\${tab 54}= ${_space_available[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}\${fs_bar 8,145 ${_mount_point[$x]}}"
done
exit 0
Kod: Zaznacz cały
#!/bin/bash
declare -a _index
declare -a _mount_point
_index=100
for x in $(hal-find-by-property --key access_control.type --string removable-block)
do
_mp=; _mp=$(hal-device "$x" |grep "volume\.mount_point" |cut -d\' -f2)
if [ "$_mp" ]
then
_index=$[--_index]
_array_index[$_index]=$_index
_mount_point[$_index]="$_mp"
_dev=$(hal-device "$x" |grep "access_control\.file" |cut -d\' -f2)
_udi=$(hal-device "$x" |grep "block\.storage_device" |cut -d\' -f2)
# _dvendor=$(hal-device "$_udi" |grep "info\.vendor" |cut -d\' -f2)
_dproduct=$(hal-device "$_udi" |grep "info\.product" |cut -d\' -f2)
# if [ "$_dvendor" ]; then _name[$_index]="${_name[$_index]} $_dvendor"; fi
if [ "$_dproduct" ]; then _name[$_index]="${_name[$_index]} $_dproduct"
else _name[$_index]="${_name[$_index]} $(hal-device $x |grep "info\.product" |cut -d\' -f2)"; fi
_name[$_index]="${_name[$_index]/\ }"
y=$(df -h |grep $(echo "$_dev"))
if [ "$y" ]
then
set $y
_device[$_index]="$1"
_space_used[$_index]="$3"
_space_free[$_index]="$4"
_percent_used[$_index]="$5"
_space_available[$_index]="$2"
fi
fi
done
for x in "${_array_index[@]}"
do
echo
echo -e "\${font :size=8:weight=bold}${_name[$x]}:"
echo -e "\${font :size=8:weight=bold}\${tab 16}device\${tab 54}= ${_device[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}mount point\${tab 54}= ${_mount_point[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space used\${tab 54}= ${_space_used[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space free\${tab 54}= ${_space_free[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}percent used\${tab 54}= ${_percent_used[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}space available\${tab 54}= ${_space_available[$x]}"
echo -e "\${font :size=8:weight=bold}\${tab 16}\${fs_bar 8,145 ${_mount_point[$x]}}"
done
exit 0
O ile pierwszy i drugi błąd da się usunąć, przez wywalenie 3 i 4 linii (co i tak nic nie daje), to ten ostatni jest dla mnie kompletnie niezrozumiały. Ma ktoś pomysł co z tym zrobić?norvoles@norvoles-desktop:~$ sh ~/.conky/conky-removable-media-debug.sh
/home/norvoles/.conky/conky-removable-media-debug.sh: 3: declare: not found
/home/norvoles/.conky/conky-removable-media-debug.sh: 4: declare: not found
/home/norvoles/.conky/conky-removable-media-debug.sh: 48: Bad substitution
Kod: Zaznacz cały
bash ~/.conky/conky-removable-media-debug.sh
Kod: Zaznacz cały
chmod +X ~/.conky/conky-removable-media-debug.sh
Kod: Zaznacz cały
~/.conky/conky-removable-media-debug.sh
Kod: Zaznacz cały
#!/usr/bin/perl
#perl script to determin mounted fs for conky
# wywołanie w conky ${execp ~/Pulpit/dysk.pl}
$filesystems = `df | grep /dev/`;
@location = split(/\n/, $filesystems);
for $i (0 .. $#location) {
if ( substr($location[$i], 0, 5) eq '/dev/' ) {
substr($location[$i], 0, 56) = "";
$loc[$a] = $location[$i];
$a++;
}
}
for $i (0 .. $#loc) {
print '${if_mounted ', $loc[$i], '}${color ', &whatcolor($loc[$i]),'}', '${fs_bar 14 ', $loc[$i], '}${color}',"\n";
print '${voffset -16}${color blue} ', $loc[$i], ' ${fs_used ', $loc[$i], '} / ${fs_size ', $loc[$i], '}${alignr 3}${fs_used_perc ', $loc[$i], '}%${else}${voffset -16}${endif}', "\n";
}
sub whatcolor {
my (@ops) = @_;
my ($status) = `df $ops[0] | grep /dev/ | cut -c52-54`;
my ($color);
if ($status > 95) { # CRITICAL
$color = 'red';
} elsif ($status > 85) { # DANGER
$color = 'orange';
} elsif ($status > 75) { # WARNING
$color = 'yellow';
} else { # GOOD
$color = 'green';
}
return $color;
}
Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 1 gość