maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   SailfishOS 2.0 on Nexus 5 (https://talk.maemo.org/showthread.php?t=94620)

Feathers McGraw 2016-01-03 12:25

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by romu (Post 1493418)
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 :D

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?

velox 2016-01-03 16:03

Re: SailfishOS 2.0 on Nexus 5
 
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…

abyzthomas 2016-01-03 16:30

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by romu (Post 1493418)
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 :D

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

romu 2016-01-03 19:50

Re: SailfishOS 2.0 on Nexus 5
 
@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.

Feathers McGraw 2016-01-03 20:09

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by Feathers McGraw (Post 1493428)
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!

Feathers McGraw 2016-01-03 20:51

Re: SailfishOS 2.0 on Nexus 5
 
3 Attachment(s)
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.

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 :confused:

BluesLee 2016-01-03 21:10

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by Feathers McGraw (Post 1493532)
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 :confused:

Perfect! Nice shark indication of activity by the way.

Feathers McGraw 2016-01-03 21:18

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by BluesLee (Post 1493534)
Works perfectly! Nice shark indication of activity the way.

:D:D "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?

BluesLee 2016-01-03 21:23

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by Feathers McGraw (Post 1493536)
:D:D "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.

velox 2016-01-03 22:41

Re: SailfishOS 2.0 on Nexus 5
 
Quote:

Originally Posted by Feathers McGraw (Post 1493536)
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.


All times are GMT. The time now is 16:15.

vBulletin® Version 3.8.8