📜 ⬆️ ⬇️

We write a simple but useful application for the Nokia N900 in 20 minutes

Greetings, dear habraiser!
In this article I will discuss the interesting properties of the Maemo operating system from the point of view
Unix system administrator. The purpose of this note is to show the convenience of writing applications for this OS.

We will write the application on Shell. Why not? - for Maemo is a native environment!

As an example, I want to give a shell script that solves a simple task: automatically connect to a home Wi-Fi access point when charging the phone . This script can be useful to those who like to hang up various tasks on the phone for the night: for example, updating RSS feeds, synchronizing with the Google calendar, updating software, etc.

Open source

In order not to be unfounded, I will cite the entire script at once:
')
#!/bin/sh ############  ############################# #  ""    ( ) sleeptime=60 # id  .    gconftool -R /system/osso/connectivity/IAP WIFI_ID="56b4d822-edd4-4692-baf2-25b0711d1e7b" # ################################################# temp=1 #    while [ $temp = "1" ]; do #    - connected  disconnected status=`hal-get-property --udi /org/freedesktop/Hal/devices/bme --key maemo.charger.connection_status` if [ $status = "connected" ]; then echo "Charger found! Trying to connect to home wifi..." #  dbus-send --system --print-reply --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"$WIFI_ID" uint32:0 # fi # sleep $sleeptime done # ####  #### 


How it works?

I would like to dwell on two lines:

  1.  status=`hal-get-property --udi /org/freedesktop/Hal/devices/bme --key maemo.charger.connection_status` 

    This command uses HAL to find out if the recharge is connected to the phone. I found the necessary udi, it seems, here , and the necessary key with the command
     lshal | grep charge 

  2.  dbus-send --system --print-reply --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"$WIFI_ID" uint32:0 

    Here we connect to the D-Bus and send a request to connect to the saved access point. The team can be found in a very useful for beginners manual Phone Control official Wiki Maemo.


I think there shouldn't be any questions regarding the rest of the script.

Installation


Next, you need to make the script work constantly in the background and add it to the “autostart”:


Conclusion


The note shows one of the easiest ways to add nice features to your N900. This script is not added: it behaves badly if there is no home access point nearby. But this problem is easily solved if you are enthusiastic and know the basics of programming. ;)

I hope this article will help newcomers in the Maemo world to take the first step to writing their useful utility.

Next time I will talk about how the Outcoming Call Vibro app wrote.

References:
- Phone Control
- D-Bus Scripts

Source: https://habr.com/ru/post/125404/


All Articles