View previous topic :: View next topic |
Author |
Message |
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Sun Nov 01, 2009 10:38 pm Post subject: Kmilo for KDE4 |
|
|
Hey,
what's the story on Kmilo for KDE 4 and Gentoo? After upgrade, I lost all the nice OSDs for my Thinkpad's extra keys.
Googling for "Kmilo KDE4" shows Ubuntu and bunch of other distributions still having this. However, I can't find it in KDEextragear or anything so I could drop a bug report with a package request, either... |
|
Back to top |
|
|
DirtyHairy l33t
Joined: 03 Jul 2006 Posts: 608 Location: Würzburg, Deutschland
|
Posted: Mon Nov 02, 2009 11:16 am Post subject: |
|
|
Afaik, though initially ported, kmilo is not available anymore for KDE4.3, which gave me some headache as well. However, portage now contains kde-misc/kosd which can be interfaced with a combination of app-laptop/tpb and a bash script using dbus-send to achieve the same effect. For example, I use the following script which I entered as a callback in ~/.tpbrc to show a nice, shiny OSD for brightness and volume changes on my T60; in addition, it displays some extended battery information when I do fn+space (=zoom)
Code: | #!/bin/bash
[ -z "$1" ] && exit
[ -z "$2" ] && exit
callout() {
method="$1"
shift
echo $@
cmd="dbus-send --print-reply --dest=\"org.kde.kosd\" \"/MainApplication\" org.kde.kosd.KOSD.$method $@ > /dev/null"
bash -c "$cmd"
}
volume() {
echo $(( `perl -e 'while (<>) {print "$1" if (m/level:\s*(\d+)/)}' /proc/acpi/ibm/volume` \
* 100 / 14 ))
}
geticon() {
icon="audio-volume-high"
[ $1 -le 70 ] && icon="audio-volume-medium"
[ $1 -le 30 ] && icon="audio-volume-low"
[ $1 -eq 0 ] && icon="audio-volume-muted"
echo $icon
}
dobattery() {
statefile="/proc/acpi/battery/BAT0/state"
infofile="/proc/acpi/battery/BAT0/info"
if [ `wc -l < $statefile` -eq 1 ]; then
icon="battery-missing"
state="Keine Batterie!"
remperc="0"
else
maxcap=`perl -e 'while (<>) {print "$1" if (m/last full capacity:\s*(\d+)/)}' \
$infofile`
remcap=`perl -e 'while (<>) {print "$1" if (m/remaining capacity:\s*(\d+)/)}' \
$statefile`
rate=`perl -e 'while (<>) {print "$1" if (m/present rate:\s*(\d+)/)}' \
$statefile`
remperc=$(( 100 * $remcap / $maxcap ))
charging=`grep " charging" $statefile`
charged=`grep "charged" $statefile`
discharging=`grep "discharging" $statefile`
state="Unbekannt"
[ -n "$charging" ] && state="Laden: $rate mW"
[ -n "$charged" ] && state="Geladen"
[ -n "$discharging" ] && state="Entladen $rate mW"
if [ -n "$discharging" ]; then
iprefix="battery"
else
iprefix="battery-charging"
fi
icon="$iprefix-100"
[ $remperc -le 80 ] && icon="$iprefix-100"
[ $remperc -le 60 ] && icon="$iprefix-060"
[ $remperc -le 40 ] && icon="$iprefix-040"
[ $remperc -le 20 ] && icon="$iprefix-low"
fi
callout showCustom string:$icon \"string:$state\" int32:$remperc
}
case $1 in
"brightness")
callout \
showCustom string:"video-display" string:"Helligkeit" int32:$2
;;
"volume")
callout \
showCustom string:`geticon $2` string:"Lautstärke" int32:$2
;;
"mute")
if [ $2 = "on" ]; then
callout showCustom string:"audio-volume-muted" string:"Stumm" int32:0
else
v=`volume`
callout showCustom string:`geticon $v` string:"Lautstärke" int32:"$v"
fi
;;
"zoom")
dobattery
;;
*)
;;
esac |
This script depends on the thinkpad acpi extras to retrieve information on volume and battery charge; the results looks pretty nice and beats the kmilo OSD in my opinion. Of course, it is also possible to use something simpler or to just use the xosd built into tpb without relying on kosd; however, I found that this doesn't play overly well with compositing. |
|
Back to top |
|
|
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Wed Nov 04, 2009 10:28 am Post subject: |
|
|
Thanks for the tip - I'll check how this works out. |
|
Back to top |
|
|
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Thu Nov 05, 2009 11:50 am Post subject: |
|
|
Ok, this works for me just fine. For other's benefit, here's the above script translated to english. Also, my .tpbrc consists of turning builtin OSD off, setting this callback script (I use ~/.tpbcb.sh), and setting the big Thinkpad key to open Konsole.
Code: |
#!/bin/bash
[ -z "$1" ] && exit
[ -z "$2" ] && exit
callout() {
method="$1"
shift
echo $@
cmd="dbus-send --print-reply --dest=\"org.kde.kosd\" \"/MainApplication\" org.kde.kosd.KOSD.$method $@ > /dev/null"
bash -c "$cmd"
}
volume() {
echo $(( `perl -e 'while (<>) {print "$1" if (m/level:\s*(\d+)/)}' /proc/acpi/ibm/volume` \
* 100 / 14 ))
}
geticon() {
icon="audio-volume-high"
[ $1 -le 70 ] && icon="audio-volume-medium"
[ $1 -le 30 ] && icon="audio-volume-low"
[ $1 -eq 0 ] && icon="audio-volume-muted"
echo $icon
}
dobattery() {
statefile="/proc/acpi/battery/BAT0/state"
infofile="/proc/acpi/battery/BAT0/info"
if [ `wc -l < $statefile` -eq 1 ]; then
icon="battery-missing"
state="No battery!"
remperc="0"
else
maxcap=`perl -e 'while (<>) {print "$1" if (m/last full capacity:\s*(\d+)/)}' \
$infofile`
remcap=`perl -e 'while (<>) {print "$1" if (m/remaining capacity:\s*(\d+)/)}' \
$statefile`
rate=`perl -e 'while (<>) {print "$1" if (m/present rate:\s*(\d+)/)}' \
$statefile`
remperc=$(( 100 * $remcap / $maxcap ))
charging=`grep " charging" $statefile`
charged=`grep "charged" $statefile`
discharging=`grep "discharging" $statefile`
state="Unknown"
[ -n "$charging" ] && state="Charging: $rate mW"
[ -n "$charged" ] && state="Charged"
[ -n "$discharging" ] && state="Discharging: $rate mW"
if [ -n "$discharging" ]; then
iprefix="battery"
else
iprefix="battery-charging"
fi
icon="$iprefix-100"
[ $remperc -le 80 ] && icon="$iprefix-100"
[ $remperc -le 60 ] && icon="$iprefix-060"
[ $remperc -le 40 ] && icon="$iprefix-040"
[ $remperc -le 20 ] && icon="$iprefix-low"
fi
callout showCustom string:$icon \"string:$state\" int32:$remperc
}
case $1 in
"brightness")
callout \
showCustom string:"video-display" string:"Brightness" int32:$2
;;
"volume")
callout \
showCustom string:`geticon $2` string:"Volume" int32:$2
;;
"mute")
if [ $2 = "on" ]; then
callout showCustom string:"audio-volume-muted" string:"Mute" int32:0
else
v=`volume`
callout showCustom string:`geticon $v` string:"Volume" int32:"$v"
fi
;;
"zoom")
dobattery
;;
*)
;;
esac
|
|
|
Back to top |
|
|
SamuliSuominen Retired Dev
Joined: 30 Sep 2005 Posts: 2133 Location: Finland
|
Posted: Thu Nov 05, 2009 11:57 am Post subject: |
|
|
Glad to hear this is working for you, this is exactly why I added kosd in portage |
|
Back to top |
|
|
DirtyHairy l33t
Joined: 03 Jul 2006 Posts: 608 Location: Würzburg, Deutschland
|
Posted: Thu Nov 05, 2009 5:49 pm Post subject: |
|
|
@Zarhan: Glad it works for you, and funny to find that other people also map the big blue button to konsole
@ssuominen: Thanks alot, the absence of an kmilo-like OSD was the only thing that was still buggering me after the transition to KDE4. |
|
Back to top |
|
|
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Thu Nov 05, 2009 7:05 pm Post subject: |
|
|
Maybe this could be wikified to Gentoo-wiki. |
|
Back to top |
|
|
DirtyHairy l33t
Joined: 03 Jul 2006 Posts: 608 Location: Würzburg, Deutschland
|
Posted: Fri Nov 06, 2009 8:48 am Post subject: |
|
|
I'm rather busy at the moment, but I might take a stab at it once I find myself with some free time again... |
|
Back to top |
|
|
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Fri Nov 13, 2009 1:51 am Post subject: |
|
|
Kosd description says it can integrate with Kmix. How would you implement this (some dbus call)?. I'm mostly thinking that when you press mute, this setting should be copied to ALSA/Kmix system too since those values are saved, so that if I mute and shut down, system starts up muted. |
|
Back to top |
|
|
DirtyHairy l33t
Joined: 03 Jul 2006 Posts: 608 Location: Würzburg, Deutschland
|
Posted: Fri Nov 13, 2009 9:34 am Post subject: |
|
|
The integration advertised by kosd works by assigning hotkeys which can then be used to trigger kosd which in turn call kmix. However, if you press the hardware volume buttons on most thinkpads, the press gets intercepted by the embedded controller which then adjusts a separate mixer which can't be controlled via the volume settings of the sound hardware. Therefore, although you can pass the volume change to kmixer via dbus (or just adjust settings with amixer), the result will be different from what you want - volume will be adjustet _twice_, first in the internal mixer and second on the sound hardware. Afaik, there is no way around this. However, the embedded mixer remembers you settings (at least on my T60), so there sould be no need to save it... |
|
Back to top |
|
|
Zarhan l33t
Joined: 27 Feb 2004 Posts: 997
|
Posted: Sat Nov 14, 2009 10:10 am Post subject: |
|
|
Ok, on my Z60m, it seems that the embedded controller forgets about staying muted (volume is remembered). |
|
Back to top |
|
|
|