You are not logged in.
I just found out, that I have an accelerometer (lis3lv02d) in my HP laptop. So I wrote a simple bash script that rotates compiz cube in direction the laptop is tilted.
Video of script in action:
http://www.youtube.com/watch?v=CtWywn1zbjA
I would post the script, but I'm a bit ashamed of my programming skills..
Offline
Ohhh, that's good !
Please post the script
Offline
As long as you don't share it, it's hardly a contribution . Every effort is appreciated, and I'm sure people will gladly (and politely) point out possible improvements. If not: there's always a report button
.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
I'll post the script here as soon as I improve it a bit..
Offline
OK, it is realy two scripts. This one is for rotating the cube with help of wmctrl (you should install wmctrl in order for it to work). I found it on the internet and shoud work on any desktop. It would be probably a better idea to do it via dbus but it doesn't seem to work for me..
#!/bin/bash
#
# compiz-rotate-wmctrl - Rotate the cube using wmctrl
#
# Author: Shang-Feng Yang
# Released under GPLv3
VER="1.0"
function rotate() {
# The target face number (begins with 0)
TVPN=$(( $1 % ${NF} ))
# The X coordinate of the target viewport
TVPX=$(( ${TVPN} * ${WW} ))
# Change to the target viewport
wmctrl -o ${TVPX},0
}
function usage() {
echo -e "$(basename $0) v${VER}\n"
echo -e "Usage:\n"
echo -e "\t$(basename $0) {left|right|#}\n"
echo -e "\tWhere:\n"
echo -e "\t\tleft - rotate the cube to the left"
echo -e "\t\tright - rotate the cube to the right"
echo -e "\t\t# - rotate to #th face (begins with 0)\n\n"
echo -e "Author: Shang-Feng Yang <storm dot sfyang at gmail dot com>"
echo -e "Released under GPLv3"
}
# The action to be performed. $ACT could be 'left' or 'right' to rotate
# left or right, accordingly. $ACT could also be the number of the face
# to rotate into.
ACT=$(echo $1 |tr '[A-Z]' '[a-z]')
[ "x$ACT" == "x" ] && { usage; exit 1; } || {
case $ACT in
left|right|[0-9]|[0-9][0-9])
;;
*)
usage
exit 1
;;
esac
}
# The informations about the desktop
INFO=$(wmctrl -d)
# The width of the desktop
DW=$(echo "${INFO}"| awk '{sub(/x[0-9]+/, "", $4); print $4}')
# The width of the workarea
WW=$(echo "${INFO}"| awk '{sub(/x[0-9]+/, "", $9); print $9}')
# The number of faces on the cube
NF=$(($DW/$WW))
# The X coordinate of the viewport
CVPX=$(echo "${INFO}" |awk '{sub(/,[0-9]+/, "", $6); print $6}')
# Current number of the face in all faces (begins with 0)
CVPN=$(( ${CVPX} / ${WW} ))
[ "$ACT" == "right" ] && {
ACT=$(( ${CVPN} + 1 ))
} || {
[ "$ACT" == "left" ] && {
ACT=$(( ${CVPN} - 1 ))
}
}
rotate ${ACT}
Next script monitors /sys/devices/platform/lis3lv02d/position. If you look at /sys/devices/platform/lis3lv02d/position you get something like: (3,6,51). First number is left/right tilt, second back/forward and last upside/downside. The script reads position value every 2 seconds and quits after 200 seconds..
#!/bin/bash
# lis3lv02d-rotate
#
# Author: Samo Turk
#
# Released under GPLv3
COUNTER=0
while [ $COUNTER -lt 100 ]; do
sleep 2
POS=`cat /sys/devices/platform/lis3lv02d/position | awk -F , '{print$1}' | awk -F "(" '{print$2}'`
echo $POS
if [ $POS -ge 12 ]; then
./compiz-rotate-wmctrl left
elif [ $POS -le -12 ]; then
./compiz-rotate-wmctrl right
fi
let COUNTER=COUNTER+1
done
So you need to have 2 scripts, the first is compiz-rotate-wmctrl and second lis3lv02d-rotate. Put them in the same folder and chmod +x for both of them and then just run ./lis3lv02d-rotate
Everything should probably be written in C and use dbus for comunicating with compiz but I don't know C...
Offline
Yeah, that's really something that will improve usability...tilting the laptop to change workspaces
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
it is not about usability, it is about health and money.
people can be forced to do some training while working on their machines which improves their workflow which is better for the company they work for which is better for the money people get from their bosses which is good for the companies who sell laptops with accelorometers because people can buy them which is good for...oh, wait, this sounds kind of familiar...
or they could go outside and have some fun with sports and their friends...
Offline
its not _not_ usable...
Offline
Just discovering some interesting things that can be done with accelerometer. Because it registers itself as a joystick device "/dev/input/js0" it can be used for exemple in google-earths flight simulator for controlling the plane..
Offline
Just discovering some interesting things that can be done with accelerometer. Because it registers itself as a joystick device "/dev/input/js0" it can be used for exemple in google-earths flight simulator for controlling the plane..
it's awesome isn't it ^^ as soon as i have some spare time on my hand, i'm gonna build a model car that i can control with my laptop's accelerometer
Offline
(Ab)Using morse code, the possibilities are endless ;-)
I have seen 1 cool application for such an accelerometer (outside the scope of safeguarding your hard disk platters if your laptop should fall of course), and that is the usage of it in combination with google street view. You could see the real life environment around the mobile's screen and the virtual environment was sort of a layer above the real life environment. So if you moved the mobile to the left, the layer followed along nicely...
Offline
Yeah, that's really something that will improve usability...tilting the laptop to change workspaces
I remember seeing a video way back in the early days of Compiz of a guy tapping the sides of his laptop to get the accelerometer to turn the cube. That was cool - and slightly more practical.
0 Ok, 0:1
Offline
(Ab)Using morse code, the possibilities are endless ;-)
I have seen 1 cool application for such an accelerometer (outside the scope of safeguarding your hard disk platters if your laptop should fall of course), and that is the usage of it in combination with google street view. You could see the real life environment around the mobile's screen and the virtual environment was sort of a layer above the real life environment. So if you moved the mobile to the left, the layer followed along nicely...
This is also known as Augmented reality, and it's totally awesome
Offline
There's a BOINC project called Quake Catcher Network, they (intend to) use computers with accelerometers for early warnings about earthquakes. I'm not sure their Linux client is up-to-date, though, and whether it supports this HP accelerometer.
Offline