Author Topic: Mapping A Keystroke To Qcop Commands  (Read 10334 times)

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« on: January 31, 2007, 09:11:53 am »
I've written a small script for toggling the input panel. (ime.sh)
It runs fine and now I'm trying to bind a keystroke to call it.

In keyhelper.conf, I added an additional line as follows

Quote
...
[Launch]
...
F26 = @qcop QPE/System 'execute(QString)' ime.sh
...

When I press Home+FirstJapKey (the one next to Ctrl), nothing happens. If I bind it as below, it calls up zeditor successfully.

Quote
...
[Launch]
...
F26 = Applications/zeditor
...

Anyone have any idea what is wrong with my call?
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

tml

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Mapping A Keystroke To Qcop Commands
« Reply #1 on: January 31, 2007, 09:18:41 am »
Quote
F26 = @qcop QPE/System 'execute(QString)' ime.sh

Make sure there is a tab after the @qcop (not a blank).
SL-C3100

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #2 on: January 31, 2007, 09:52:31 am »
Quote
Quote
F26 = @qcop QPE/System 'execute(QString)' ime.sh

Make sure there is a tab after the @qcop (not a blank).
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153030\"][{POST_SNAPBACK}][/a][/div]

Gee, thanks! That works brilliantly! Who would have guessed that!!
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #3 on: January 31, 2007, 11:26:15 am »
hmmm ... strangely, it seem to work, as in it blanks the screen but does not do anything.
Occassionally, home+key do not work altogether.

btw, my script ime.sh is as below
(I created a empty file at /home/tmp/ime_off)
Code: [Select]
#!/bin/sh
if [ -f /home/tmp/ime_on ]; then
    qcop    QPE/TaskBar 'hideInputMethod()'
    mv /home/tmp/ime_on /home/tmp/ime_off
else
    qcop    QPE/TaskBar 'showInputMethod()'
    mv /home/tmp/ime_off /home/tmp/ime_on
fi
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

tml

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Mapping A Keystroke To Qcop Commands
« Reply #4 on: January 31, 2007, 02:37:24 pm »
Quote
hmmm ... strangely, it seem to work, as in it blanks the screen but does not do anything.
[/code]
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153039\"][{POST_SNAPBACK}][/a][/div]

It probably tries to change resolution or so. The execute command tries to start a qpe qpe application which a sh script is not, I think. I'd say you'd have to wrap the script into something qtopian but maybe there's a simpler solution.
SL-C3100

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #5 on: January 31, 2007, 02:48:56 pm »
Quote
Quote
hmmm ... strangely, it seem to work, as in it blanks the screen but does not do anything.
[/code]
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153039\"][{POST_SNAPBACK}][/a][/div]

It probably tries to change resolution or so. The execute command tries to start a qpe qpe application which a sh script is not, I think. I'd say you'd have to wrap the script into something qtopian but maybe there's a simpler solution.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153065\"][{POST_SNAPBACK}][/a][/div]

I see ... hmmm ... is there maybe a way for keyhelper app to run a .sh script directly?
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mapping A Keystroke To Qcop Commands
« Reply #6 on: January 31, 2007, 10:49:56 pm »
Quote
hmmm ... strangely, it seem to work, as in it blanks the screen but does not do anything.
Occassionally, home+key do not work altogether.

btw, my script ime.sh is as below
(I created a empty file at /home/tmp/ime_off)
Code: [Select]
#!/bin/sh
if [ -f /home/tmp/ime_on ]; then
    qcop    QPE/TaskBar 'hideInputMethod()'
    mv /home/tmp/ime_on /home/tmp/ime_off
else
    qcop    QPE/TaskBar 'showInputMethod()'
    mv /home/tmp/ime_off /home/tmp/ime_on
fi
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153039\"][{POST_SNAPBACK}][/a][/div]

your qcop commands need to run as the zaurus user. maybe your script is called as root user.
try something like

su zaurus -c    "qcop   QPE/TaskBar 'hideInputMethod()'"
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #7 on: January 31, 2007, 11:35:52 pm »
Quote
your qcop commands need to run as the zaurus user. maybe your script is called as root user.
try something like

su zaurus -c  "qcop   QPE/TaskBar 'hideInputMethod()'"
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153134\"][{POST_SNAPBACK}][/a][/div]

ok, modified as per above, still shows a black blank screen and returns after awhile without toggling input panel.

Further, running the script from konsole causing the script to ask for password.
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

bam

  • Hero Member
  • *****
  • Posts: 1213
    • View Profile
    • http://thegrinder.ws
Mapping A Keystroke To Qcop Commands
« Reply #8 on: January 31, 2007, 11:38:53 pm »
try creating an icon that calls the script then call the icon of the script via qcop channel
SL-C3100 current: Stock/Tetsu 18h
Socket BT CF Card
Linksys WCF-12 802.11b/Cheapie USB Ethernet

The Grinder

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #9 on: February 01, 2007, 12:15:59 am »
Quote
try creating an icon that calls the script then call the icon of the script via qcop channel
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153140\"][{POST_SNAPBACK}][/a][/div]

hmmm ... sounds like a plan!
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #10 on: February 01, 2007, 12:30:06 am »
ok, so far seems to work ...  ... but takes like 3 seconds to do it!

Thanks all for the input and suggestions!
Once I get to my notebook, I'll write a C app to do it properly. My only hurdle is compiling for Z ... something I haven't come up to speed.

btw, meanie, can I gcc natively using gcc from pdaXqtrom?
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Mapping A Keystroke To Qcop Commands
« Reply #11 on: February 01, 2007, 12:34:20 am »
Quote
ok, so far seems to work ...  ... but takes like 3 seconds to do it!

Thanks all for the input and suggestions!
Once I get to my notebook, I'll write a C app to do it properly. My only hurdle is compiling for Z ... something I haven't come up to speed.

btw, meanie, can I gcc natively using gcc from pdaXqtrom?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153153\"][{POST_SNAPBACK}][/a][/div]

of course you can. my zgcc image supports both qte and xqt
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
Mapping A Keystroke To Qcop Commands
« Reply #12 on: February 01, 2007, 06:10:07 pm »
Quote
Quote
ok, so far seems to work ...  ... but takes like 3 seconds to do it!

Thanks all for the input and suggestions!
Once I get to my notebook, I'll write a C app to do it properly. My only hurdle is compiling for Z ... something I haven't come up to speed.

btw, meanie, can I gcc natively using gcc from pdaXqtrom?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153153\"][{POST_SNAPBACK}][/a][/div]

of course you can. my zgcc image supports both qte and xqt
[div align=\"right\"][a href=\"index.php?act=findpost&pid=153154\"][{POST_SNAPBACK}][/a][/div]

Roger that, thanks!
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>