Hammerhead Torch

Your rating: None Average: 4.3 (7 votes)

A simple torch app, originally written for the LG Nexus 5 (codename "hammerhead") port of Sailfish OS. Uses GStreamer by default, with hardware specific workarounds for some other ported devices.

Now supports:

  • Nexus 5 ("hammerhead")
  • Jolla phone
  • Fairphone 2
  • Motorola Photon Q
  • Motorola Moto-G (2013)

Hardware specific workarounds for devices where gstreamer is not fully supported can be added easily for any other phone with a simple control file that turns the LED on depending on its content (i.e. 1 for on, 0 for off) - get in touch if you would like me to add support for your device!

License: GPLv2+

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

Application versions: 
File harbour-hammerhead-torch-0.1-1.armv7hl.rpm90.37 KB04/01/2016 - 00:31
File harbour-hammerhead-torch-0.2-1.armv7hl.rpm91.38 KB04/01/2016 - 23:33
File harbour-hammerhead-torch-0.4-1.armv7hl.rpm95.68 KB07/01/2016 - 01:43
File harbour-hammerhead-torch-0.5-1.armv7hl.rpm94.78 KB07/01/2016 - 23:16
File harbour-hammerhead-torch-0.6-1.armv7hl.rpm95.54 KB09/01/2016 - 02:44
File harbour-hammerhead-torch-0.7-1.armv7hl.rpm138.22 KB08/06/2016 - 01:23
File harbour-hammerhead-torch-0.8-1.armv7hl.rpm138.53 KB11/06/2016 - 17:33
File harbour-hammerhead-torch-0.9-1.armv7hl.rpm137.93 KB14/06/2016 - 21:55
File harbour-hammerhead-torch-0.10-1.armv7hl.rpm138.96 KB25/06/2016 - 15:05
File harbour-hammerhead-torch-0.11-1.armv7hl.rpm140.16 KB28/06/2016 - 00:02
File harbour-hammerhead-torch-0.12-1.armv7hl.rpm144.09 KB05/07/2016 - 02:28
File harbour-hammerhead-torch-0.13-1.armv7hl.rpm144.18 KB21/01/2017 - 20:31

- Added support for Motorola Moto-G (2013)


KyleB's picture

Great simple torch app, can confirm it works on the moto g 2014 no modifications needed

moofang's picture

Chiming in that this works (with gstreamer) on aqua fish :)

May or may not mean it works for Jollac i guess.

Feathers_McGraw's picture

GStreamer, baby! :D

Feathers_McGraw's picture

I'd like to hear from people using Jolla C, since I don't have one and haven't been able to test the experimental support. Let me know!

Feathers_McGraw's picture

Now supports Motorola Photon Q, thanks to elros34


If anyone else is using a SFOS port, please get in touch and we can add support for your device.

mika77's picture

With the latest release works like a charm, thank you ^^

Feathers_McGraw's picture

You're welcome :)

Shervrar's picture

Sorry if this is stupid, but why not create a link from /sys/class/leds/led:flash_torch/brightness to /sys/kernel/debug/flash_adp1650/mode? Wouldn't that make the hammerhead univertally compatible with Jolla Phone applications that use flash?

Feathers_McGraw's picture

Hi, good question :)

Some of the other apps seem to work by creating a camera stream and controlling the flashlight that way, so I don't think creating that symlink would work for the other apps. Although the camera stream method seems convoluted it is probably more portable in theory if libhybris can abstract the locations of all the control files etc (that's just a guess, I don't know how libhybris works).

That's not the way this app works because it was originally written specifically for Hammerhead, and I only added support for jPhone because someone asked. When I started the app I didn't even know that jPhone has a file that controls the flashlight!

You're right that in theory I could make the app jPhone only, and then ask all Hammerhead users to manually create the jPhone folder structure and symlink as root, but that would be a lot less convenient.

Rikudou_Sennin's picture

not working on Jolla :)

Feathers_McGraw's picture

Should be fixed now, can you confirm?

There were two bugs - firstly the function to detect the control file wasn't working properly because it detected the correct path and then overrode it (so the app was writing to the wrong file).

Secondly, even if the correct path was manually specified, the method I was using to write to the control file (QFile & QTextStream) that works on Hammerhead doesn't work on the Jolla control file for some reason, even though nemo has permissions to read and write it :S. QFile would say it was successful in opening the file read+write in truncate (overwrite) mode, but then qtextstream couldn't get position 0, which i think means it couldn't navigate to the start of the file to overwrite it.

I think this is the same reason you can't cat the contents of the control file in a terminal even though you have read permission. Maybe it has some additional constraints?

Anyway, I completely rewrote that bit so it just calls echo with QProcess. It's now working on my Jolla, hopefully that re-write didn't break it on Hammerhead!

Rikudou_Sennin's picture

Works now. But you should definitely hide the settings - letting user write into any file is a bad idea.

Feathers_McGraw's picture

Thanks for testing :)

Not sure if I agree about the file path. The user shouldn't have to use that setting unless they have a Sailfish port on a device other than Hammerhead, since jPhone and Hammerhead are auto-detected. If they have a different device, they need to be able to set the path somehow - the whole point of the app was to be a torch for phones that can't use the apps that assume every phone is a jPhone. The app runs as nemo so it can only write to files that the user can already modify anyway, so I don't see the problem.

I agree about turning the torch on when the app starts though, I almost implemented that tonight but I wanted to get a version that works on both phones out first. I'll do it tomorrow.

Rikudou_Sennin's picture

User should never use that setting. Don't allow people do bad things if you don't have to.

They don't have to be able to set the path somehow - they will not know, where the path should point. You should make a bulletproof class that checks the phone files and if it does not find any of the files, show something like feedback form for them to contact you.

The problem about nemo writing only to files that the user already can - the file on Jolla, that controls torch is owned by root, yet you can still write to it. There may be other files like that and not doing something that innocent.

You should really never give basic user such option.

Feathers_McGraw's picture

I think you're being quite patronising and underestimating people, particularly users who are capable of installing SFOS on Hammerhead and other devices that don't come preloaded with SFOS.

The chance of someone accidentally typing the wrong path that just happens to be a real path to a file that nemo can write to, that will break the whole system if overwritten with a 1 or 0 is vanishingly small.

Nevertheless, I've removed the option to set the path to the control file in the GUI. The settings page now just displays the path to the control file and the device name, and describes how to change the settings in the config file.

Feathers_McGraw's picture

I know :( , looking into it.

Rikudou_Sennin's picture

And one more advice: you should start the torch as soon as the app opens - when people use torch, they want light. Or you should make a setting for it at least.

mika77's picture

Hi ^^ nice to see an open source torch app. I suggest you to make it work also with Jolla phone. The one on the store doesn't work on Jolla phones with the last updates, and it's closed source. Hope to see this app for both Nexus 5 and Jolla phone on Harbour ^^

coderus's picture

This works forever: https://openrepos.net/content/drgogeta86/lumino

Also Flashlight from Store works great on latest and very latest sailfish version.

mika77's picture

No, flashlight from store doesn't work always. If you updated your phone from 1.9 releases to 2xxxx release it works, but if your phone comes with 2xxxx preinstalled doesn't work.

coderus's picture

sounds like problem on your phone. i just installed flashlight from store and it just works.

Feathers_McGraw's picture

Tonight I got Hammerhead Torch working with the Jolla phone, the app now autodetects Jolla/hammerhead by checking to see if the control files exist on first run, and stores the result in a config file. I also added a way to support any other phone with a similar control file by specifying its location, just need to polish that bit and then I'll release the new version tomorrow :)

Feathers_McGraw's picture


If I can work out how to control the torch on in the Jolla phone, I'll add support for it. At the moment, this app just writes 1 or 0 to a text file at /sys/class/leds/led:flash_torch/brightness, which turns the torch on/off on Hammerhead. The file doesn't exist on the Jolla, but there's probably a more elegant way to do it anyway. I'll have a rummage!


Rikudou_Sennin's picture

On Jolla, there is no elegant way.

echo 1 > /sys/kernel/debug/flash_adp1650/mode
echo 0 > /sys/kernel/debug/flash_adp1650/mode

Feathers_McGraw's picture

Hmm... that file is owned by root on Jolla so there must be another way, because the other apps don't have permissions to write to that file!

On hammerhead the control file is writable by nemo.

Rikudou_Sennin's picture

I had no problem writing to it as nemo.

Feathers_McGraw's picture

Looking again, although it's owned by root:root everyone has write permissions. Thanks for pointing this out, should be pretty trivial to add support for the Jolla phone :)

Rikudou_Sennin's picture

Also, for hammerhead and Jolla you should also check for camera app open and stop light if it does

Rikudou_Sennin's picture

Correct me if I'm wrong, wouldn't the app in store work for hammerhead, while it's arm?

Feathers_McGraw's picture