View Single Post
Posts: 539 | Thanked: 165 times | Joined on Feb 2010 @ Berlin, Germany
#1
First of all I should mention that I don't have a clue where to post this how-to. So I put it to General. If it's not the right place, please move it.

OK, in germany there is a provider called e-plus who changed the way of telling the current balance in last summer. Actually, when querying *100# (thanks god for ussd-widget!!) the user gets a message saying, that the balance will be sent by SMS within the next moments. The SMS arrives, but ussd-widget of course still shows the intermediate message. This was very annoying for me so I figured out a way to get the balance right on the desktop.

All you need is the packages ussd-widget and desktop-command-execution. Please keep in mind that installing 3rd-party software and executing this how-to might kill a randomly selected kitten somewhere in the suburbs. But probably not

Step 1: install and configure one instance of ussd-widget. At least you need to fill in the field for the ussd code; it must contain '*100#' (without the quotes). Make sure it works and you receive the SMS containing the balance. There must be at least one of these SMSs stored on your phone to get this how-to to work.

Step 2: install desktop-command-execution. There is no need to put one of the pre-defined commands on your desktop if you don't want to.

Step 3: create a file in your home folder (should not be placed in MyDocs as this is a sometimes-unmounted-FAT-filesystem and I just don't know if a script can get executed from there reliable) copy the following code to it and make it executable.

Step-by-step:

Assumed the file is called /home/user/Guthaben.sh type the following into the terminal (as user, not root):
Code:
cat > /home/user/Guthaben.sh
then copy this text and paste it in (or type it in)
Code:
#!/bin/sh
# simple query to the RTCOM database:
# - selects the last incoming SMS beginning with the string "Ihr Guthaben"
# - formats the output to only display date and account balance in €

sqlite3 -separator ": " /home/user/.rtcom-eventlogger/el.db \
 "SELECT strftime('%d.%m.%Y',storage_time,'unixepoch','localtime'), free_text FROM Events WHERE event_type_id = '7' AND free_text LIKE 'Ihr Guthaben%' ORDER BY end_time DESC LIMIT 1"\
 | sed s/Ihr.*gt\ // | sed s/.EUR./€/
Now press <ctrl>-<d> to close the file.

Instead of the described command you might use any other editor or whatever-tool-you-like, as long as it is able to write a standard textfile.

Now make the script executable (again: in terminal):
Code:
chmod u+x /home/user/Guthaben.sh
Test the script by typing
Code:
/home/user/Guthaben.sh <enter>
You should now see a line with the date and the balance of the last query. If not, something went wrong.

Last step: put one instance of desktop-command-execution on your desktop and go to the settings. Push "add cmd" and enter the path and filename to your script (i.e.: /home/user/Guthaben.sh) into the field "Command:". In the field "Title:" you may put whatever you like, I used 'Guthaben'. You just have to remember it . Save the settings. The just added command should now be selected. If not, open the command list and select it (now you need to remember the name you gave it). Adjust the other options to your needs and save the widget.

If nothing went bad, you should see your actual balance on desktop.

For convenience I modified the output of ussd-widget, as the complete answer from e-plus is too ugly to have it on desktop all day. Now the answer is displayed in a short note and the widget just changes it's name. This is what I did (just the names of the fields I changed and their value):

Name: Guthaben
Parser for widget: echo "Kto abgefragt"
Enable banner: yes
Parser: echo "%"
Font: Nokia Sans Cn Regular 16


Have fun!
 

The Following 5 Users Say Thank You to x-lette For This Useful Post: