Active Topics

 


Reply
Thread Tools
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#321
Originally Posted by romu View Post
Oh great, thank you. Now, we just need to package this into something more usable than a terminal. Personaly, I can't, but I would greatly appreciate
I started an app called Hammerhead Torch yesterday, with a bit of luck I should finish today seemed like a neat little project for my first Sailfish app.

Since the file is owned by root:root, it will probably require changing permissions/ownership of that file so that the app can write to it, at least until I can work out how to turn it on the "right way".

Seems like the kind of thing libhybris handles, but I couldn't find any info on how to actually use it. Anyone know how?
 

The Following 2 Users Say Thank You to Feathers McGraw For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#322
I have never done something like this (and it sounds like the wrong thing to do), but you might be able to add chmod commands to a %post script (don't forget to undo on %postun if it even works) in your rpm spec file to change permissions on installation…
__________________
slumber: sensors enabled sleep timer for SFOS (translations/input/… appreciated if you've got some spare time)
talefish: directory based audiobook player for SFOS
nofono: ofono restart for SFOS
___
list of i486/noarch packages on openrepos (jolla tablet)
 

The Following 2 Users Say Thank You to velox For This Useful Post:
Posts: 307 | Thanked: 488 times | Joined on Sep 2010 @ USA around Chicago
#323
Originally Posted by romu View Post
Oh great, thank you. Now, we just need to package this into something more usable than a terminal. Personaly, I can't, but I would greatly appreciate
Here is a way you can do it.

I would create a folder called scripts under nemo home directory so you can keep your scripts together. It is not are requirement.

Create a file /home/nemo/scripts/flashlight.sh and copy the following to it.

Code:
#!/bin/bash
FLASHCTL=/sys/class/leds/led\:flash_torch/brightness
FLASHON=`cat $FLASHCTL`

if [ "$FLASHON" == 0 ]
then
   /bin/echo 1 > $FLASHCTL
else
   /bin/echo 0 > $FLASHCTL
fi
Create the icon file /usr/share/applications/flashlight.desktop and copy the following. Icon=flashlight expects a png file in /usr/share/icons/hicolor/86x86/apps/flashlight.png

Code:
[Desktop Entry]
Type=Application
Icon=flashlight
Exec=/home/nemo/scripts/flashlight.sh
Name=Flash Light
The above will create an icon that turns flashlight on and off.

Hope this helps to get you going.

Edit:

Make sure the script is executable.
Code:
chmod 755 /home/nemo/scripts/flashlight.sh
__________________
Apps for iPhone & iPad
Malayalam Keyboard for iPhoneTelugu Keyboard for iPhoneGujarati Keyboard for iPhone

Last edited by abyzthomas; 2016-01-03 at 16:46.
 

The Following 7 Users Say Thank You to abyzthomas For This Useful Post:
Posts: 602 | Thanked: 735 times | Joined on Mar 2011 @ Nantes, France
#324
@abyzthomas: it works...almost. It doesn't behave like a regular SFOS application, so it's not obvious about how to close it properly. But that's better than nothing. Thanks a lot.
 

The Following 2 Users Say Thank You to romu For This Useful Post:
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#325
Originally Posted by Feathers McGraw View Post
Since the file is owned by root:root, it will probably require changing permissions/ownership of that file so that the app can write to it
Actually I think I might have been wrong there. nemo belongs to the "system" group, and (on the Jolla phone at least) some of those LED files are owned by system:system.

Code:
nemo ~ $ ls -l /sys/class/leds/led\:rgb_red/            
total 0
-rw-r--r-- 1 system system 4096 Dec 31 00:03 blink_delay_off
-rw-r--r-- 1 system system 4096 Dec 31 00:03 blink_delay_on
-rw-r--r-- 1 system system 4096 Dec 31 00:03 brightness
lrwxrwxrwx 1 root   root      0 Jan  3 20:04 device -> ../../../pm8xxx-led
-rw-r--r-- 1 root   root   4096 Dec 31 00:03 max_brightness
drwxr-xr-x 2 root   root      0 Jan  3 20:04 power
lrwxrwxrwx 1 root   root      0 Jan  3 20:04 subsystem -> ../../../../../../../class/leds    
-rw-r--r-- 1 root   root   4096 Jan  3 20:04 uevent

What are the permissions/ownership of the files on the N5?
I haven't actually received mine yet!
 

The Following User Says Thank You to Feathers McGraw For This Useful Post:
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#326
So I made an app:



I don't have a N5 yet so if someone can test for me I'd really appreciate it! RPMs are attached.

EDIT: sauce https://github.com/sam-hobbs/harbour-hammerhead-torch

EDIT: now on openrepos https://openrepos.net/content/feathe...mmerhead-torch

It works fine editing a file in /home/nemo in the emulator, but I can't create the file /sys/class/leds/led:flash_torch/brightness in the emulator which is really annoying!

So I think it will work, but it might not.

Also, can someone explain what the difference between debug and release modes is in the SDK? I thought release mode just removed debugging symbols or something like that, but I get no errors compiling in debug mode and lots in release mode

Last edited by Feathers McGraw; 2016-01-03 at 22:43. Reason: added openrepos link
 

The Following 6 Users Say Thank You to Feathers McGraw For This Useful Post:
BluesLee's Avatar
Posts: 411 | Thanked: 1,105 times | Joined on Jan 2010 @ Europe
#327
Originally Posted by Feathers McGraw View Post
So I made an app:

http://i.imgur.com/ZytGbjP.png

I don't have a N5 yet so if someone can test for me I'd really appreciate it! RPMs are attached. I'll upload the source to Github after posting this.

It works fine editing a file in /home/nemo in the emulator, but I can't create the file /sys/class/leds/led:flash_torch/brightness in the emulator which is really annoying!

So I think it will work, but it might not.

Also, can someone explain what the difference between debug and release modes is in the SDK? I thought release mode just removed debugging symbols or something like that, but I get no errors compiling in debug mode and lots in release mode
Perfect! Nice shark indication of activity by the way.
 

The Following 2 Users Say Thank You to BluesLee For This Useful Post:
Feathers McGraw's Avatar
Posts: 654 | Thanked: 2,368 times | Joined on Jul 2014 @ UK
#328
Originally Posted by BluesLee View Post
Works perfectly! Nice shark indication of activity the way.
"muh first app"!

Did you have to change any permissions?

Only thing that's bugging me about it is that if you toggle the flashlight from the cover action it won't update the icon when you open the main page and vice versa.

On "traditional" Qt I'd do this with signals and slots but it's taking a while to get my head around Qml and the docs aren't great either compared to normal Qt, which is understandable.

The best I could do for now is to use onStatusChanged on the main page (see here), but that only works when switching between pages within the app (try main page to about and back, and it will refresh); it doesn't work when switching between the cover and the app itself.

Are there any signals for when different pages gain focus or anything like that?
 

The Following 3 Users Say Thank You to Feathers McGraw For This Useful Post:
BluesLee's Avatar
Posts: 411 | Thanked: 1,105 times | Joined on Jan 2010 @ Europe
#329
Originally Posted by Feathers McGraw View Post
"muh first app"!

Did you have to change any permissions?

Only thing that's bugging me about it is that if you toggle the flashlight from the cover action it won't update the icon when you open the main page and vice versa.

On "traditional" Qt I'd do this with signals and slots but it's taking a while to get my head around Qml and the docs aren't great either compared to normal Qt, which is understandable.

The best I could do for now is to use onStatusChanged on the main page (see here), but that only works when switching between pages within the app (try main page to about and back, and it will refresh); it doesn't work when switching between the cover and the app itself.

Are there any signals for when different pages gain focus or anything like that?
No, i did not change any permissions. You are right regarding toggling and the behaviour between main page and cover.
 

The Following 2 Users Say Thank You to BluesLee For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#330
Originally Posted by Feathers McGraw View Post
Are there any signals for when different pages gain focus or anything like that?
I hope I understood your underlying problem, because I think it should work without listening for focus: You could make a bool property in your LEDControl in the main qml which you can query in all other qml files with something like
Code:
    Image {
        source: ( led.isOnBool ) ? "qrc:///hammerhead-inverted" : "qrc:///hammerhead"
    }
and would not have to set the source/whatever manually on change, just set the bool.
__________________
slumber: sensors enabled sleep timer for SFOS (translations/input/… appreciated if you've got some spare time)
talefish: directory based audiobook player for SFOS
nofono: ofono restart for SFOS
___
list of i486/noarch packages on openrepos (jolla tablet)

Last edited by velox; 2016-01-03 at 22:48.
 

The Following 2 Users Say Thank You to velox For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 20:08.