• Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Power options - not inhibiting sleep

    Scheduled Pinned Locked Moved
    Technical Help
    1
    3
    521
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nashoba
      last edited by

      First thing first, I must say: Kudos for excellent work (...and choosing Snowy White for screenshots 🤗 ).

      Now, the only problem on my Kubuntu laptop is that Strawberry don't implement any power options. To be precise, after time defined in OS settings my laptop will go to sleep, although Strawberry is still playing.

      Earlier, as a workaround, I could start Strawberry with .desktop file containing:

      Exec=bash -c 'inhibit_lock=$(qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.Inhibit "strawberry" "playing") ; /path/Strawberry-0.9.3-Qt5-x86_64.AppImage %U ; qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.UnInhibit $inhibit_lock'
      

      but since v0.9.3 that, for some reason, that will not work, nether for Qt5 nor Qt6 appimage. The same thing is with outdated 0.8.3 deb version. Well, you can imagine how annoying it is.

      Anyway, Godspeed and if I may a little advice.
      If you plan to get Strawberry viral, you really need to implement that modern album grid view for Collection sidebar as some have been requested it, maybe something like KDE's Elisa. Now, I don't promise to use it, but still, you get the point.
      Best of luck.

      N 1 Reply Last reply Reply Quote 2
      • N
        nashoba @nashoba
        last edited by

        @nashoba
        Apparently, it's a change in powerdevil.
        If anyone interested for a MR it's explained here:

        https://www.reddit.com/r/kde/comments/hruubo/unable_to_inhibit_suspend/

        1 Reply Last reply Reply Quote 0
        • N
          nashoba
          last edited by

          Actual solution:
          Now this can be easily achieved by simple python script and as a result, Plasma will correctly recognise inhibition in it's default "Battery and Brightness" widget:

          #!/usr/bin/env python3
          
          import dbus, subprocess, sys
          
          session_bus = dbus.SessionBus()
          
          obj = session_bus.get_object('org.freedesktop.PowerManagement.Inhibit', 
                                       '/org/freedesktop/PowerManagement/Inhibit')
          iface = dbus.Interface(obj, dbus_interface='org.freedesktop.PowerManagement.Inhibit')
          data = iface.Inhibit(str(sys.argv[1]), '\nfor reason: playing music')
          
          # Output report
          print(f'''\n----------
          {sys.argv[0]}
              script inhibiting program: "{sys.argv[1]}"
              with cookie: {data}
              To release inhibit manually run:\n
              " qdbus org.freedesktop.PowerManagement.Inhibit
              /org/freedesktop/PowerManagement/Inhibit
              org.freedesktop.PowerManagement.Inhibit.UnInhibit {data} " 
          ----------\n''')
          
          process = subprocess.run(sys.argv[1:], stderr=subprocess.STDOUT)
          sys.exit(process.returncode)
          

          As a bonus, it will work with any other program, too. To use it, call script with program as arguments. For example, in desktop file:

          Exec=/pathToScript/inhibit_sleep.py    /path_to_executable/Strawberry-0.9.3-Qt5-x86_64.AppImage %U
          

          It will disable inhibition right after you exit Strawberry.

          @devs
          Well, it's not PyQt as an effort to be more portable, but from the top of my head, it can be easily achieved with QDBusConnection and QDBusInterface classes.

          1 Reply Last reply Reply Quote 1
          • D demux referenced this topic on
          • First post
            Last post
          Powered by NodeBB | Contributors