Announcement

Collapse
No announcement yet.

Trying to perfect my first "solid" action. Where to find complete list of entries?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trying to perfect my first "solid" action. Where to find complete list of entries?

    I'm have written a "Eject" feature for removable devices because if you choose "Safely Remove" it powers down and disconnects the device. I find this is highly annoying because you now have to pull the USB stick or SDCard out and re-insert it to use again.

    I have it written and it totally works:
    Code:
    [Desktop Entry]
    Actions=open;
    Type=Service
    X-KDE-Action-Custom=true
    X-KDE-Solid-Predicate=[ IS StorageVolume AND StorageVolume.ignored == false ]
    
    [Desktop Action open]
    Exec=udisksctl unmount -b %d
    Icon=media-eject
    Name=Unmount Removable Device


    The code above is in ~/.local/share/solid/actions/eject_removable.desktop and works immediately when the file is placed there. When I select "Disks and Devices"

    The part I need help with is a want to option to unmount to only appear when the device is actually mounted. I believe this is the line that might make this happen:
    Code:
    X-KDE-Solid-Predicate=[ IS StorageVolume AND StorageVolume.ignored == false ]
    but I tried to add "AND StorageVolume.mounted == true" and this only causes the action to not show at all. It seems the option I want is not what I guessed at.

    What I'm asking is if anyone knows of a resource that has all the available Predicates in it. I've gone through the KDE tutorial but have found no index.

    Please Read Me

    #2
    I provide the following not because I don't think you don't know about it, but because maybe it's so simple a solution you've overlooked it.

    Google query: in Ubuntu Linux, is there a way to Eject a removable USB device without powering it down?

    AI Overview

    Yes, in Ubuntu Linux, you can unmount (eject) a USB device to safely remove it without cutting power to the port by
    using umount` in the terminal or by choosing "Eject" instead of "Safely Remove" in the file manager. This detaches the file system while keeping the USB device active.






















    Windows no longer obstruct my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      The point of using a "solid" action is to avoid having to launch the file manager or use the terminal to eject a USB device. The devices already appear in "Disk & Devices" so by adding a solid action to my account, I can "eject" (unmount) without other tools. Think of it like a shortcut.

      It's comparable to "Reformat or Edit with File Manager" that is in Disk & Devices by default. One certainly can manually launch KDE Partition Manager and select a device. Or you can select the device AND launch Partition Manager in one go from Disk & Devices.

      Please Read Me

      Comment


        #4
        AI Overview

        To safely eject a USB device in KDE without powering it off, use the predicate
        StorageAccess.accessible == false. This ensures the device is unmounted (making it safe to remove) but does not trigger udisksctl to power down the drive. This predicate can be used in Action rules, as seen in this discussion on KDE Discuss.

        Recommended Solid Predicates
        • StorageAccess.accessible == false: The best option to simply unmount the filesystem.
        • OpticalDisc.available == false: If the device is detected specifically as an optical drive (CD/DVD).

        Why X-KDE-Solid-Predicate Often Powers Off
        Modern KDE (using udisks2) treats "Safely Remove" as a signal to fully power down the USB device, which causes it to disappear from the GUI entirely. The predicates above help to only stop file system access, leaving the USB powered.

        Alternatives if Predicates Fail
        If the drive still powers down, you may need to use a custom action with a shell script instead of a Solid predicate:
        • Unmount and Sync: udisksctl unmount -b /dev/sdX && sync.
        • Keep Powered: Avoid udisksctl power-off.
        If you're interested in managing these settings, you might want to look into the KDE Solid documentation.






















        Windows no longer obstruct my view.
        Using Kubuntu Linux since March 23, 2007.
        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

        Comment


          #5
          In KDE Solid, the property is StorageVolume.isMounted, not StorageVolume.mounted.
          Try this line :
          X-KDE-Solid-Predicate=[ IS StorageVolume AND StorageVolume.isMounted == true AND StorageDrive.isRemovable == true ]

          That last bit makes it so it only targets removable devices

          ʟɨռʊӼ ʄօʀ ʟɨʄɛ

          Comment


            #6
            Unfortunately, that's not what I'm looking for. At this point what I would like a list of what "Predicates" exist and their valid options. For example, "StorageVolume.ignored == false" works but "StorageVolume.mounted" does not. "StorageAccess.accessible == true" does not work so I think that predicate is a trigger, not a condition.

            I've gone though all the tutorials but they all use the same examples and none so far have lead to actual DOCUMENTATION that isn't just a description of what solid is and does.

            I just want to RTFM

            Please Read Me

            Comment


              #7
              Another odd thing: the "Mount" function that exists in the menu appears or disappears depending on the condition of the device. If it's already mounted - there is no "Mount" option displayed. If it is NOT mounted, the option is presented.

              The ultimate end result would be for my "Unmount" option to have the same behavior, but I am unable to locate the source on the Mount option (to copy the code) anywhere so far. It is definitely NOT in /usr/share/solid/actions/

              Please Read Me

              Comment


                #8
                Originally posted by die.boer View Post
                In KDE Solid, the property is StorageVolume.isMounted, not StorageVolume.mounted.
                Try this line :
                X-KDE-Solid-Predicate=[ IS StorageVolume AND StorageVolume.isMounted == true AND StorageDrive.isRemovable == true ]

                That last bit makes it so it only targets removable devices

                Unfortunately that's not working here at all.

                Please Read Me

                Comment


                  #9
                  I did manage to find this: https://api.kde.org/solid-storagevolume.html

                  which does not list "isMounted" as a valid value. I do see references to it in Android docs tho.

                  Please Read Me

                  Comment


                    #10
                    At least I located the API for this project. Just no option that I can use has worked so far - the goal being to have the Unmount action only available if the device is already mounted.

                    Please Read Me

                    Comment


                      #11
                      maybe if you change the StorageVolume , to StorageAccess ?
                      like X-KDE-Solid-Predicate=[ IS StorageAccess AND StorageAccess.isAccessible == true ]
                      https://api.kde.org/solid-storageaccess.html
                      Last edited by die.boer; Mar 04, 2026, 05:03 PM.
                      ʟɨռʊӼ ʄօʀ ʟɨʄɛ

                      Comment


                        #12
                        Still not working I even tried that option alone and no-go

                        Please Read Me

                        Comment


                          #13
                          I've tried dozens on combinations and so far the ONLY time the action shows up is with:

                          X-KDE-Solid-Predicate=[IS StorageVolume AND StorageVolume.ignored == false ]

                          Please Read Me

                          Comment


                            #14
                            do you log out/in after changes?

                            edit: and try change the exec line to Exec=sh -c 'udisksctl info -b %d | grep -q "Mounted: yes" && udisksctl unmount -b %d'
                            (with the X-KDE-Solid-Predicate=[IS StorageVolume AND StorageVolume.ignored == false ] predicates)
                            Last edited by die.boer; Mar 04, 2026, 05:18 PM.
                            ʟɨռʊӼ ʄօʀ ʟɨʄɛ

                            Comment


                            • oshunluvr
                              oshunluvr commented
                              Editing a comment
                              You don't have to log out to activate the changes to a solid action. The files are read when you access the widget. So simply closing the Disk & Devices window and re-opening it shows the new edits.

                            #15
                            Thanks for your help.

                            If the device is already unmounted the command does nothing - meaning no negative impact

                            What I'm trying to achieve is to have the Unmount function not appear at all if the device isn't mounted just like Mount does.

                            Here, you can see the top device is not mounted but both Mount and Unmount are visible.
                            But the lower device is mounted and the Mount command is hidden as it is redundant.

                            Click image for larger version

Name:	Screenshot_20260305_101923.jpg
Views:	35
Size:	50.5 KB
ID:	690828
                            I was hoping to locate the code that inserts the Mount command and maybe get some hints, but it's not a solid action and I have been unsuccessful in my search. I actually just noticed the Check for Errors action is also hidden when the device is mounted but also not a solid action. HOWEVER Open with File Manager IS a solid action. Looking at that now!

                            Please Read Me

                            Comment

                            Users Viewing This Topic

                            Collapse

                            There are 0 users viewing this topic.

                            Working...
                            X