We have moved to a new Sailfish OS Forum. Please start new discussions there.

Revision history [back]

click to hide/show revision 1
initial version

posted 2017-11-04 00:18:15 +0200

Patch for skipping tracks with volume rocker (help needed)

Ahoy there. Please correct me if I'm wrong but as far as I see, that issue is still relevant and there is (was) no way to skip tracks with volume rocker. So after taking a look into some other patches and docs I've created a quick and dirty patch for VolumeControl.qml. It is as follows (here is the pastebin upload of it):

--- "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-02 21:04:52.000000000 +0300
+++ "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-04 00:33:09.000000000 +0300
@@ -10,6 +10,7 @@
 import Sailfish.Silica 1.0
 import org.nemomobile.systemsettings 1.0
 import org.nemomobile.configuration 1.0
+import org.nemomobile.mpris 1.0
 import QtFeedback 5.0
 import "../systemwindow"
 import "../compositor"
@@ -17,6 +18,8 @@
 SystemWindow {
     id: volumeBar

+    MprisManager { id: mprisManager }
+    
     property bool volumeIncreasing
     property bool lateScreenshotCapture
     property var screenshot
@@ -453,7 +456,13 @@
         repeat: true
         onTriggered: {
             if (volumeBar.controllingMedia) {
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                if (volumeIncreasing)
+                    mprisManager.previous()
+                else
+                    mprisManager.next()
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                initialChange = 0
             } else {
                 profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
             }
@@ -488,14 +497,10 @@
             volumeBar.volumeIncreasing = (key == Qt.Key_VolumeUp)

             if (volumeBar.controllingMedia) {
-                if (volumeIncreasing)
-                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
-                else
-                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
-
+                initialChange = 0
+                baseVolume = volumeControl.volume
                 keyRepeat.stop()
                 keyRepeatDelay.restart()
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
             } else {
                 if (volumeControl.windowVisible) {
                     if (volumeIncreasing)
@@ -518,7 +523,14 @@
         onVolumeKeyReleased: {
             initialChange = 0
             if (volumeBar.controllingMedia)
-                baseVolume = volumeControl.volume
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                if (volumeIncreasing)
+                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
+                else
+                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
+                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                
             if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
                 // Handle pressing both buttons and releasing the first, though
                 // in that case keyRepeat is probably already stopped by screenshotTimer

As one may notice, it does the following things:

  1. Imports MPRIS interface.
  2. Tinkers with the KeyRepeat timer — now, if the volume key controls the media volume (meaning there is an active media player) the timer does not change volume when triggered (and, as it was before, it is triggered when the volume up or down button is held for 600 ms). Instead it sends MPRIS signal for any compatible player to change to previous or next track. Of course single press still changes the music volume.
  3. Changes volume rocker behaviour (again only when there is an active player). Now the volume changes on the key release.

Sadly I'm not a mobile or QML developer and frankly, not a developer at all. So if you have any ideas on improvement of that code — please do share them.

And the important point — there is still major issue: on the release of the volume key the volume is altered regardless of whether the keyRepeat timer was triggered (and the track changed). As far as I understand (again sorry, but I'm really not a developer) there must be a connection made to the keyRepeat timer signal. But if somebody would be so kind to show how it is done or propose alternative solution I'd be quite grateful.

For now the VolumeControl.qml sections in question are as follows:

Timer {
    id: keyRepeat
    interval: volumeBar.controllingMedia ? 75 : 300
    repeat: true
    onTriggered: {
        if (volumeBar.controllingMedia) {
            if (volumeIncreasing)
                mprisManager.previous()
            else
                mprisManager.next()
            keyRepeat.stop()
            keyRepeatDelay.stop()
            initialChange = 0
        } else {
            profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
        }

        restartHideTimerIfWindowVisibleAndWarningNotVisible()
    }
}

onVolumeKeyReleased: {
    initialChange = 0
    if (volumeBar.controllingMedia)
        keyRepeat.stop()
        keyRepeatDelay.stop()
        if (volumeIncreasing)
            initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
        else
            initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
        volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)

    if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
        // Handle pressing both buttons and releasing the first, though
        // in that case keyRepeat is probably already stopped by screenshotTimer
        keyRepeat.stop()
        keyRepeatDelay.stop()
    }
    screenshotTimer.stop()
    lateScreenshotCapture = false
}

And the last one: the patch is tested with 2.1.1.26. I do not think that there are major changes in that area in 2.1.2, but bear it in mind.

Patch for skipping tracks with volume rocker (help needed)

Ahoy there. Please correct me if I'm wrong but as far as I see, that issue is still relevant and there is (was) no way to skip tracks with volume rocker. So after taking a look into some other patches and docs I've created a quick and dirty patch for VolumeControl.qml. It is as follows (here is the pastebin upload of it):

--- "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-02 21:04:52.000000000 +0300
+++ "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-04 00:33:09.000000000 +0300
@@ -10,6 +10,7 @@
 import Sailfish.Silica 1.0
 import org.nemomobile.systemsettings 1.0
 import org.nemomobile.configuration 1.0
+import org.nemomobile.mpris 1.0
 import QtFeedback 5.0
 import "../systemwindow"
 import "../compositor"
@@ -17,6 +18,8 @@
 SystemWindow {
     id: volumeBar

+    MprisManager { id: mprisManager }
+    
     property bool volumeIncreasing
     property bool lateScreenshotCapture
     property var screenshot
@@ -453,7 +456,13 @@
         repeat: true
         onTriggered: {
             if (volumeBar.controllingMedia) {
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                if (volumeIncreasing)
+                    mprisManager.previous()
+                else
+                    mprisManager.next()
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                initialChange = 0
             } else {
                 profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
             }
@@ -488,14 +497,10 @@
             volumeBar.volumeIncreasing = (key == Qt.Key_VolumeUp)

             if (volumeBar.controllingMedia) {
-                if (volumeIncreasing)
-                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
-                else
-                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
-
+                initialChange = 0
+                baseVolume = volumeControl.volume
                 keyRepeat.stop()
                 keyRepeatDelay.restart()
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
             } else {
                 if (volumeControl.windowVisible) {
                     if (volumeIncreasing)
@@ -518,7 +523,14 @@
         onVolumeKeyReleased: {
             initialChange = 0
             if (volumeBar.controllingMedia)
-                baseVolume = volumeControl.volume
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                if (volumeIncreasing)
+                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
+                else
+                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
+                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                
             if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
                 // Handle pressing both buttons and releasing the first, though
                 // in that case keyRepeat is probably already stopped by screenshotTimer

As one may notice, it does the following things:

  1. Imports MPRIS interface.
  2. Tinkers with the KeyRepeat timer — now, if the volume key controls the media volume (meaning there is an active media player) the timer does not change volume when triggered (and, as it was before, it is triggered when the volume up or down button is held for 600 ms). Instead it sends MPRIS signal for any compatible player to change to previous or next track. Of course single press still changes the music volume.
  3. Changes volume rocker behaviour (again only when there is an active player). Now the volume changes on the key release.

Sadly I'm not a mobile or QML developer and frankly, not a developer at all. So if you have any ideas on improvement of that code — please do share them.

And the important point — there is still major issue: on the release of the volume key the volume is altered regardless of whether the keyRepeat timer was triggered (and the track changed). As far as I understand (again sorry, but I'm really not a developer) there must be a connection made to the keyRepeat timer signal. But if somebody would be so kind to show how it is done or propose alternative solution I'd be quite grateful.

For now the VolumeControl.qml sections in question are as follows:

Timer {
    id: keyRepeat
    interval: volumeBar.controllingMedia ? 75 : 300
    repeat: true
    onTriggered: {
        if (volumeBar.controllingMedia) {
            if (volumeIncreasing)
                mprisManager.previous()
            else
                mprisManager.next()
            keyRepeat.stop()
            keyRepeatDelay.stop()
            initialChange = 0
        } else {
            profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
        }

        restartHideTimerIfWindowVisibleAndWarningNotVisible()
    }
}

onVolumeKeyReleased: {
    initialChange = 0
    if (volumeBar.controllingMedia)
        keyRepeat.stop()
        keyRepeatDelay.stop()
        if (volumeIncreasing)
            initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
        else
            initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
        volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)

    if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
        // Handle pressing both buttons and releasing the first, though
        // in that case keyRepeat is probably already stopped by screenshotTimer
        keyRepeat.stop()
        keyRepeatDelay.stop()
    }
    screenshotTimer.stop()
    lateScreenshotCapture = false
}

And the Here is the full finished product — you can save it as /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml

The last one: the patch is tested with 2.1.1.26. I do not think that there are major changes in that area in 2.1.2, but bear it in mind.

Patch for skipping tracks with volume rocker (help needed)

Update: the issue below is still relevant, but for the time being I've just altered the patch in such a way that when the volume key is held down it changes volume in one direction, and when the key is released — in the other. I do understand that is not what you call elegant.

Any ideas or attempts to rewrite it, package it for the patchmanager and so on are welcome.

Archive with the patch and modified VolumeControl.qml: VolumeControl.tar.gz You can apply the patch manually (don't forget to backup) or just replace your original /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml (bear in mind that the mine on is for 2.1.1.26).


Ahoy there. Please correct me if I'm wrong but as far as I see, that issue is still relevant and there is (was) no way to skip tracks with volume rocker. So after taking a look into some other patches and docs I've created a quick and dirty patch for VolumeControl.qml. It is as follows (here is the pastebin upload of it):

--- "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-02 21:04:52.000000000 +0300
+++ "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-04 00:33:09.000000000 +0300
@@ -10,6 +10,7 @@
 import Sailfish.Silica 1.0
 import org.nemomobile.systemsettings 1.0
 import org.nemomobile.configuration 1.0
+import org.nemomobile.mpris 1.0
 import QtFeedback 5.0
 import "../systemwindow"
 import "../compositor"
@@ -17,6 +18,8 @@
 SystemWindow {
     id: volumeBar

+    MprisManager { id: mprisManager }
+    
     property bool volumeIncreasing
     property bool lateScreenshotCapture
     property var screenshot
@@ -453,7 +456,13 @@
         repeat: true
         onTriggered: {
             if (volumeBar.controllingMedia) {
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                if (volumeIncreasing)
+                    mprisManager.previous()
+                else
+                    mprisManager.next()
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                initialChange = 0
             } else {
                 profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
             }
@@ -488,14 +497,10 @@
             volumeBar.volumeIncreasing = (key == Qt.Key_VolumeUp)

             if (volumeBar.controllingMedia) {
-                if (volumeIncreasing)
-                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
-                else
-                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
-
+                initialChange = 0
+                baseVolume = volumeControl.volume
                 keyRepeat.stop()
                 keyRepeatDelay.restart()
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
             } else {
                 if (volumeControl.windowVisible) {
                     if (volumeIncreasing)
@@ -518,7 +523,14 @@
         onVolumeKeyReleased: {
             initialChange = 0
             if (volumeBar.controllingMedia)
-                baseVolume = volumeControl.volume
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                if (volumeIncreasing)
+                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
+                else
+                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
+                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                
             if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
                 // Handle pressing both buttons and releasing the first, though
                 // in that case keyRepeat is probably already stopped by screenshotTimer

As one may notice, it does the following things:

  1. Imports MPRIS interface.
  2. Tinkers with the KeyRepeat timer — now, if the volume key controls the media volume (meaning there is an active media player) the timer does not change volume when triggered (and, as it was before, it is triggered when the volume up or down button is held for 600 ms). Instead it sends MPRIS signal for any compatible player to change to previous or next track. Of course single press still changes the music volume.
  3. Changes volume rocker behaviour (again only when there is an active player). Now the volume changes on the key release.

Sadly I'm not a mobile or QML developer and frankly, not a developer at all. So if you have any ideas on improvement of that code — please do share them.

And the important point — there is still major issue: on the release of the volume key the volume is altered regardless of whether the keyRepeat timer was triggered (and the track changed). As far as I understand (again sorry, but I'm really not a developer) there must be a connection made to the keyRepeat timer signal. But if somebody would be so kind to show how it is done or propose alternative solution I'd be quite grateful.

For now the VolumeControl.qml sections in question are as follows:

Timer {
    id: keyRepeat
    interval: volumeBar.controllingMedia ? 75 : 300
    repeat: true
    onTriggered: {
        if (volumeBar.controllingMedia) {
            if (volumeIncreasing)
                mprisManager.previous()
            else
                mprisManager.next()
            keyRepeat.stop()
            keyRepeatDelay.stop()
            initialChange = 0
        } else {
            profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
        }

        restartHideTimerIfWindowVisibleAndWarningNotVisible()
    }
}

onVolumeKeyReleased: {
    initialChange = 0
    if (volumeBar.controllingMedia)
        keyRepeat.stop()
        keyRepeatDelay.stop()
        if (volumeIncreasing)
            initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
        else
            initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
        volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)

    if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
        // Handle pressing both buttons and releasing the first, though
        // in that case keyRepeat is probably already stopped by screenshotTimer
        keyRepeat.stop()
        keyRepeatDelay.stop()
    }
    screenshotTimer.stop()
    lateScreenshotCapture = false
}

Here is the full finished product — you can save it as /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml

The last one: the patch is tested with 2.1.1.26. I do not think that there are major changes in that area in 2.1.2, but bear it in mind.

Patch for skipping tracks with volume rocker (help needed)rocker

Update: the issue below is still relevant, but for the time being I've just altered the patch in such a way that when the volume key is held down it changes volume in one direction, and when the key is released — in the other. I do understand that is not what you call elegant.

Any ideas or attempts to rewrite it, package it for the patchmanager and so on are welcome.

Archive with the patch and modified VolumeControl.qml: VolumeControl.tar.gz

You can apply the patch manually (don't forget to backup) or just replace your original /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml (bear in mind that the mine on one is for 2.1.1.26).


Ahoy there. Please correct me if I'm wrong but as far as I see, that issue is still relevant and there is (was) no way to skip tracks with volume rocker. So after taking a look into some other patches and docs I've created a quick and dirty patch for VolumeControl.qml. It is as follows (here is the pastebin upload of it):

--- "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-02 21:04:52.000000000 +0300
+++ "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-04 00:33:09.000000000 +0300
@@ -10,6 +10,7 @@
 import Sailfish.Silica 1.0
 import org.nemomobile.systemsettings 1.0
 import org.nemomobile.configuration 1.0
+import org.nemomobile.mpris 1.0
 import QtFeedback 5.0
 import "../systemwindow"
 import "../compositor"
@@ -17,6 +18,8 @@
 SystemWindow {
     id: volumeBar

+    MprisManager { id: mprisManager }
+    
     property bool volumeIncreasing
     property bool lateScreenshotCapture
     property var screenshot
@@ -453,7 +456,13 @@
         repeat: true
         onTriggered: {
             if (volumeBar.controllingMedia) {
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                if (volumeIncreasing)
+                    mprisManager.previous()
+                else
+                    mprisManager.next()
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                initialChange = 0
             } else {
                 profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
             }
@@ -488,14 +497,10 @@
             volumeBar.volumeIncreasing = (key == Qt.Key_VolumeUp)

             if (volumeBar.controllingMedia) {
-                if (volumeIncreasing)
-                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
-                else
-                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
-
+                initialChange = 0
+                baseVolume = volumeControl.volume
                 keyRepeat.stop()
                 keyRepeatDelay.restart()
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
             } else {
                 if (volumeControl.windowVisible) {
                     if (volumeIncreasing)
@@ -518,7 +523,14 @@
         onVolumeKeyReleased: {
             initialChange = 0
             if (volumeBar.controllingMedia)
-                baseVolume = volumeControl.volume
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                if (volumeIncreasing)
+                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
+                else
+                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
+                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                
             if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
                 // Handle pressing both buttons and releasing the first, though
                 // in that case keyRepeat is probably already stopped by screenshotTimer

As one may notice, it does the following things:

  1. Imports MPRIS interface.
  2. Tinkers with the KeyRepeat timer — now, if the volume key controls the media volume (meaning there is an active media player) the timer does not change volume when triggered (and, as it was before, it is triggered when the volume up or down button is held for 600 ms). Instead it sends MPRIS signal for any compatible player to change to previous or next track. Of course single press still changes the music volume.
  3. Changes volume rocker behaviour (again only when there is an active player). Now the volume changes on the key release.

Sadly I'm not a mobile or QML developer and frankly, not a developer at all. So if you have any ideas on improvement of that code — please do share them.

And the important point — there is still major issue: on the release of the volume key the volume is altered regardless of whether the keyRepeat timer was triggered (and the track changed). As far as I understand (again sorry, but I'm really not a developer) there must be a connection made to the keyRepeat timer signal. But if somebody would be so kind to show how it is done or propose alternative solution I'd be quite grateful.

For now the VolumeControl.qml sections in question are as follows:

Timer {
    id: keyRepeat
    interval: volumeBar.controllingMedia ? 75 : 300
    repeat: true
    onTriggered: {
        if (volumeBar.controllingMedia) {
            if (volumeIncreasing)
                mprisManager.previous()
            else
                mprisManager.next()
            keyRepeat.stop()
            keyRepeatDelay.stop()
            initialChange = 0
        } else {
            profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
        }

        restartHideTimerIfWindowVisibleAndWarningNotVisible()
    }
}

onVolumeKeyReleased: {
    initialChange = 0
    if (volumeBar.controllingMedia)
        keyRepeat.stop()
        keyRepeatDelay.stop()
        if (volumeIncreasing)
            initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
        else
            initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
        volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)

    if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
        // Handle pressing both buttons and releasing the first, though
        // in that case keyRepeat is probably already stopped by screenshotTimer
        keyRepeat.stop()
        keyRepeatDelay.stop()
    }
    screenshotTimer.stop()
    lateScreenshotCapture = false
}

Here is the full finished product — you can save it as /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml

The last one: the patch is tested with 2.1.1.26. I do not think that there are major changes in that area in 2.1.2, but bear it in mind.

Patch for skipping tracks with volume rocker

Update 2019-08-16: see the updated VolumeControl.qml for the 3.1.0. Modifications are the same as earlier.

Update: the issue below is still relevant, but for the time being I've just altered the patch in such a way that when the volume key is held down it changes volume in one direction, and when the key is released — in the other. I do understand that is not what you call elegant.

Any ideas or attempts to rewrite it, package it for the patchmanager and so on are welcome.

Archive with the patch and modified VolumeControl.qml: VolumeControl.tar.gz

You can apply the patch manually (don't forget to backup) or just replace your original /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml (bear in mind that the mine one is for 2.1.1.26).


Ahoy there. Please correct me if I'm wrong but as far as I see, that issue is still relevant and there is (was) no way to skip tracks with volume rocker. So after taking a look into some other patches and docs I've created a quick and dirty patch for VolumeControl.qml. It is as follows (here is the pastebin upload of it):

--- "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-02 21:04:52.000000000 +0300
+++ "/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml"    2017-11-04 00:33:09.000000000 +0300
@@ -10,6 +10,7 @@
 import Sailfish.Silica 1.0
 import org.nemomobile.systemsettings 1.0
 import org.nemomobile.configuration 1.0
+import org.nemomobile.mpris 1.0
 import QtFeedback 5.0
 import "../systemwindow"
 import "../compositor"
@@ -17,6 +18,8 @@
 SystemWindow {
     id: volumeBar

+    MprisManager { id: mprisManager }
+    
     property bool volumeIncreasing
     property bool lateScreenshotCapture
     property var screenshot
@@ -453,7 +456,13 @@
         repeat: true
         onTriggered: {
             if (volumeBar.controllingMedia) {
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                if (volumeIncreasing)
+                    mprisManager.previous()
+                else
+                    mprisManager.next()
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                initialChange = 0
             } else {
                 profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
             }
@@ -488,14 +497,10 @@
             volumeBar.volumeIncreasing = (key == Qt.Key_VolumeUp)

             if (volumeBar.controllingMedia) {
-                if (volumeIncreasing)
-                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
-                else
-                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
-
+                initialChange = 0
+                baseVolume = volumeControl.volume
                 keyRepeat.stop()
                 keyRepeatDelay.restart()
-                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
             } else {
                 if (volumeControl.windowVisible) {
                     if (volumeIncreasing)
@@ -518,7 +523,14 @@
         onVolumeKeyReleased: {
             initialChange = 0
             if (volumeBar.controllingMedia)
-                baseVolume = volumeControl.volume
+                keyRepeat.stop()
+                keyRepeatDelay.stop()
+                if (volumeIncreasing)
+                    initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
+                else
+                    initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
+                volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)
+                
             if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
                 // Handle pressing both buttons and releasing the first, though
                 // in that case keyRepeat is probably already stopped by screenshotTimer

As one may notice, it does the following things:

  1. Imports MPRIS interface.
  2. Tinkers with the KeyRepeat timer — now, if the volume key controls the media volume (meaning there is an active media player) the timer does not change volume when triggered (and, as it was before, it is triggered when the volume up or down button is held for 600 ms). Instead it sends MPRIS signal for any compatible player to change to previous or next track. Of course single press still changes the music volume.
  3. Changes volume rocker behaviour (again only when there is an active player). Now the volume changes on the key release.

Sadly I'm not a mobile or QML developer and frankly, not a developer at all. So if you have any ideas on improvement of that code — please do share them.

And the important point — there is still major issue: on the release of the volume key the volume is altered regardless of whether the keyRepeat timer was triggered (and the track changed). As far as I understand (again sorry, but I'm really not a developer) there must be a connection made to the keyRepeat timer signal. But if somebody would be so kind to show how it is done or propose alternative solution I'd be quite grateful.

For now the VolumeControl.qml sections in question are as follows:

Timer {
    id: keyRepeat
    interval: volumeBar.controllingMedia ? 75 : 300
    repeat: true
    onTriggered: {
        if (volumeBar.controllingMedia) {
            if (volumeIncreasing)
                mprisManager.previous()
            else
                mprisManager.next()
            keyRepeat.stop()
            keyRepeatDelay.stop()
            initialChange = 0
        } else {
            profileControl.adjustRingtoneVolume(volumeBar.volumeIncreasing ? 20 : -20)
        }

        restartHideTimerIfWindowVisibleAndWarningNotVisible()
    }
}

onVolumeKeyReleased: {
    initialChange = 0
    if (volumeBar.controllingMedia)
        keyRepeat.stop()
        keyRepeatDelay.stop()
        if (volumeIncreasing)
            initialChange = volumeControl.volume === volumeControl.maximumVolume ? 0 : -1 / (volumeControl.maximumVolume+1)
        else
            initialChange = volumeControl.volume === 0 ? 0 : 1 / (volumeControl.maximumVolume+1)
        volumeControl.volume = volumeControl.volume + (volumeBar.volumeIncreasing ? 1 : -1)

    if (volumeBar.volumeIncreasing == (key == Qt.Key_VolumeUp)) {
        // Handle pressing both buttons and releasing the first, though
        // in that case keyRepeat is probably already stopped by screenshotTimer
        keyRepeat.stop()
        keyRepeatDelay.stop()
    }
    screenshotTimer.stop()
    lateScreenshotCapture = false
}

Here is the full finished product — you can save it as /usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml

The last one: the patch is tested with 2.1.1.26. I do not think that there are major changes in that area in 2.1.2, but bear it in mind.