You are not logged in.

#1 2024-01-11 04:01:26

barney
Member
Registered: 2020-12-14
Posts: 130

jmtpfs and mtp kio slave

I don't want to use mtp kio slave to mount my phone, but it gets automatically mounted by the KDE.
when I use the command

jmtpfs ~/mnt

I get the following message:

 Device 0 (VID=12d1 and PID=107e) is a Huawei P9 Plus.
libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device
terminate called after throwing an instance of 'MtpErrorCantOpenDevice'
  what():  Can't open device
Aborted (core dumped)

I have read somewhere on the internet that placing the file org.kde.kmtpd5.service in ~/.local/share/dbus-1/services/ with this content:

[D-BUS Service]
Hidden=true
Name=org.kde.kmtpd5

can disable the auto-mount of the phone, but that didnt helped. With that file, when I issue the command

jmtpfs ~/mnt

I get the message that the phone is successfully mounted, but when I list the content of the ~/mnt I get the message of I/O error.
How can I disable the auto-mount of the phone and use jmtpfs?

Offline

#2 2024-01-11 13:49:47

barney
Member
Registered: 2020-12-14
Posts: 130

Re: jmtpfs and mtp kio slave

I have found this bug report https://bugs.kde.org/show_bug.cgi?id=412257
I am having exactly that problem.

Offline

#3 2024-01-11 15:44:35

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: jmtpfs and mtp kio slave

kio-extra ships
/usr/lib/qt/plugins/kf5/kio/mtp.so
/usr/lib/qt/plugins/kf5/kiod/kmtpd.so
/usr/share/dbus-1/services/org.kde.kmtpd5.service

You could try to simply move those somewhere else™

Offline

#4 2024-01-12 00:53:57

barney
Member
Registered: 2020-12-14
Posts: 130

Re: jmtpfs and mtp kio slave

seth wrote:

kio-extra ships
/usr/lib/qt/plugins/kf5/kio/mtp.so
/usr/lib/qt/plugins/kf5/kiod/kmtpd.so
/usr/share/dbus-1/services/org.kde.kmtpd5.service

You could try to simply move those somewhere else™

It is working, but it is not satisfactory. This way the kio slave is disabled permanently and for all users. Not all users knows about mounting device.
The kio slave should not be so aggressive to occupy the device exclusively for itself. There should be button connect to device and after that button release device.
Some general question. How the kio slave get invoked? there must be some udev rule to invoke the kio slave? How the udev knows that that device is mtp device?

Offline

#5 2024-01-12 08:09:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: jmtpfs and mtp kio slave

How the kio slave get invoked?

Some KDE automounting feature, I assume. Or because you clicked on the drive in dolphin.

The kio slave should not be so aggressive to occupy the device exclusively for itself. There should be button connect to device and after that button release device.

Yes "should" …
Yet there's an open upstream bug since 2019 - don't use KDE *shrug*

Offline

#6 2024-01-12 09:20:30

barney
Member
Registered: 2020-12-14
Posts: 130

Re: jmtpfs and mtp kio slave

don't use KDE *shrug*

Which desktop environment is most simple and most stable?

Offline

#7 2024-01-12 09:28:30

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: jmtpfs and mtp kio slave

"No desktop environment".

This is going nowhere, if you're bothered by the mtp kio, get it out of the way, upstream has obviously no interest in fixing this.
If you want to keep using KDE, check whether disabling automounting helps you.

Offline

#8 2024-01-12 09:43:26

barney
Member
Registered: 2020-12-14
Posts: 130

Re: jmtpfs and mtp kio slave

This is going nowhere ...

Opposite, I have learned that desktop environment is not the best solution, but I need some graphics environment, for viewing PDF's, browsing the internet, libre office ...
I don't know where to start? You are experienced user maybe you could give me some advice about the setup should I use, and link how to achieve that.

Offline

#9 2024-01-12 13:56:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: jmtpfs and mtp kio slave

There're plenty of windowmanagers and GUI tools for all sorts of purposes - your preferences will decide your setup.

1. wayland or X11
2. tiling or stacking WM ?
3. panel? how do you intend to mount drives at all? Do you want to rely more on CLI tools or do you prefer GUI buttons for interacting with the system?

https://wiki.archlinux.org/title/Window_manager

I use a zsh script around udisks and simple-mtpfs to juggle drives (with fancy autocompletion), but that doesn't necessarily suit you.
There's no SethOS and if there was, it'd probably not be very beginner-friendly (I'm currently running compiz because I felt fancy and I wanted to see whether I could go w/o any UI, there's no titlebars or panels or anything like that)

Offline

#10 2024-01-12 15:28:39

barney
Member
Registered: 2020-12-14
Posts: 130

Re: jmtpfs and mtp kio slave

seth wrote:

There're plenty of windowmanagers and GUI tools for all sorts of purposes - your preferences will decide your setup.

1. wayland or X11

I have Nvidia card and I have read that wayland and Nvidia are not good choice. Maybe the new versions of drivers have changed that?

2. tiling or stacking WM ?
3. panel? how do you intend to mount drives at all? Do you want to rely more on CLI tools or do you prefer GUI buttons for interacting with the system?

I will read more about WM, but for now I will go with i3w, simply because I have found good tutorials about i3w and arch. I want to use CLI tools. About the drives I don't know what are my options?

I use a zsh script around udisks and simple-mtpfs to juggle drives (with fancy autocompletion), but that doesn't necessarily suit you.
There's no SethOS and if there was, it'd probably not be very beginner-friendly (I'm currently running compiz because I felt fancy and I wanted to see whether I could go w/o any UI, there's no titlebars or panels or anything like that)

Where can I find tips and tricks about udisks? I am not at the point for SethOS, but I will make some experiments with window managers and tools oriented on CLI.
Thanks Seth for your advice.

Offline

#11 2024-01-12 21:33:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,048

Re: jmtpfs and mtp kio slave

https://wiki.archlinux.org/title/Udisks
There're https://wiki.archlinux.org/title/Udisks#Mount_helpers and for completeness sake here's my wrapper (it's zsh function and zsh completion, it won't properly work in bash and the part about ejecting optical drives isn't properly tested… because it's an optical drive)

_disk() {
    if (( CURRENT == 2 )); then
        local ACTIONS=(mount attach add unmount umount remove detach eject)
        compadd "${ACTIONS[@]}"
        return
    fi
    (( CURRENT > 3 )) && return
    
    local EJECT
    case "${words[2]}" in
        mount|attach|add) EJECT=false ;;
        unmount|umount|remove|detach|eject) EJECT=true ;;
        *) return 1 ;;
    esac

    local DEVICES=()
    local ROOT_DEV=$(findmnt -no SOURCE /)
    ROOT_DEV=${ROOT_DEV:0:-1}
    
    while read line; do
        eval $line
        if [ "$RM" = "1" ] && [ "$TYPE" = "rom" ] && [ -z $FSTYPE ]; then # optical, not mounted
            DEVICES+="$MODEL"
            continue
        fi
        if $EJECT; then
            [[ "$MOUNTPOINT" != "/run/media/${USER}/"* ]] && continue # not a udisks mount
        else
            [ ! -z "$MOUNTPOINT" ] && continue # already mounted
        fi
        [ "$TYPE" = "disk" -a "$FSTYPE" = "" ] && continue # partitioned drive
        [ "$FSTYPE" = "swap" ] && continue # swap
        [[ "$NAME" =~ "$ROOT_DEV" ]] && continue
        [ -n "$LABEL" ] && DEVICES+="$LABEL" || DEVICES+="$NAME"
    done < <(lsblk -Ppno NAME,LABEL,MOUNTPOINT,FSTYPE,SIZE,TYPE,RM,MODEL,UUID)
    while read LABEL; do
        if mount | grep "simple-mtpfs on /run/media/$USER/$LABEL" > /dev/null 2>&1; then
            $EJECT && DEVICES+="$LABEL"
        else
            $EJECT || DEVICES+="$LABEL"
        fi
    done < <(simple-mtpfs -l 2>/dev/null | awk '/:/{print $2}')
    
    compadd "${DEVICES[@]}"
}

disk() {
    local EJECT
    case "$1" in
        mount|attach|add) EJECT=false ;;
        unmount|umount|remove|detach|eject) EJECT=true ;;
        *) return 1 ;;
    esac

    while read ID LABEL JUNK; do
        if [ "$LABEL" = "$2" ]; then
            sudo -v
            if $EJECT; then
                ( (sudo /bin/sh -c "fusermount -u /run/media/$USER/$LABEL && rm -d /run/media/$USER/$LABEL" && notify-send -u low "Unmounted $LABEL ⏏" || 
                notify-send -u critical "$2 is opened by $(ps --no-headers -o comm,pid $(lsof -t -- "/run/media/$USER/$LABEL"))") & )
            else
                ( (sudo /bin/sh -c "mkdir -p /run/media/$USER/$LABEL && /usr/bin/simple-mtpfs /run/media/$USER/$LABEL -o allow_other --device ${ID%%:*}" && \
                                 notify-send -u low "Mounted $LABEL ?") & )
            fi
            return
        fi
    done < <(simple-mtpfs -l 2>/dev/null)
    while read line; do
        eval $line
        if [ "$LABEL" = "$2" -o "$NAME" = "$2" -o "$MODEL" = "$2" ]; then
            if $EJECT; then
                ( (udisksctl unmount -b $NAME > /dev/null 2>&1 && notify-send -u low "Unmounted $2 ⏏" || 
                notify-send -u critical "$2 is opened by $(ps --no-headers -o comm,pid $(lsof -t -- "/run/media/$USER/$LABEL"))"; \
                    [ "$RM" = "1" ] && [ "$TYPE" = "rom" ] && [ "$1" = "eject" ] && eject "$NAME" ) & )
            else
                ( ( [ "$RM" = "1" ] && [ "$TYPE" = "rom" ] && eject -t "$NAME"; \
                    udisksctl mount -b $NAME > /dev/null 2>&1 && notify-send -u low "Mounted $2 ?" ) & )
            fi
            return
        fi
    done < <(lsblk -Ppno NAME,LABEL,RM,TYPE,MODEL)
}

compdef _disk disk

Offline

Board footer

Powered by FluxBB