Giter VIP home page Giter VIP logo

Comments (9)

coldfix avatar coldfix commented on June 3, 2024 1

Is the solution implemented in #127 enough for your needs? Try:

udiskie --notify-command "zenity --info --text '{event}: {device_presentation}'"

It's not quite as generic since it doesn't allow multiple handlers nor handler lookup based on event types, but you could implement that in the executed script. We could also make it possible to configure multiple handlers via the config, but I'm not sure whether it's worth the effort.

from udiskie.

coldfix avatar coldfix commented on June 3, 2024

Hey,

udiskie allows event handlers to connect on_mount/on_unlock - but: currently there is no builtin facility to add external (not inside the udiskie codebase) event listeners. The following options could be implemented rather easily:

  • directly add on_xxx handlers in the udiskie config file. Then there is the question if only python objects are allowed or general shell commands and which arguments should be passed.
  • add python objects that can have multiple on_xxx handlers and directly get added on process startup.

But I guess, the easiest way to do this is using the udisks API directly. It's not that hard, I can write up a small example. Just, I have a friend coming over and don't have much time right now.

As for your second suggestion: getting the password from a user command. That is certainly interesting. I have long wanted to make it possible to customize the password prompt, but hesitated to put some ad-hoc solution in, especially since I wanted to make udiskie asynchronous first. I will have to think about this, but this is something that I almost certainly would like to go in.

from udiskie.

chmduquesne avatar chmduquesne commented on June 3, 2024

I'll look in the udisk api, then :)

from udiskie.

chmduquesne avatar chmduquesne commented on June 3, 2024

Actually it is unnecessary to use the udisks api. This simple script does the trick.

#!/bin/bash

# uuid of the encrypted partition (the one that appears after you unlock the disk)
uuid=3afa3bd4-f025-11e4-90ec-1681e6b88ec1

inotifywait --monitor --event create --format '%f' /media/ | \
    while read file; do
        case $file in
            $uuid)
                notify-send -u critical "Backup starting!" "Do NOT unplug the disk"
                sleep 1 # rsync fails with bad permissions if you don't sleep
                rsync -avz --delete  $HOME/ /media/$uuid
                notify-send -u critical "Backup finished" "You can now eject the device"
                ;;
            *)
                ;;
        esac
    done

I suspect that in order to get rid of the sleep command, I could even replace the inotifywait command with something like udisksctl monitor | grep $uuid

from udiskie.

coldfix avatar coldfix commented on June 3, 2024

Great, you found your own solution. Unless you want further advice, you can close the issue (or I'll do it).

from udiskie.

nachoparker avatar nachoparker commented on June 3, 2024

Hi,

Thanks for udiskie. I also think that this would be an excelent feature to have. Just being able to hook commands to actions so we do not have to rely on hideous udev rules.

This would be a killer feature IMHO

I don't have much time right now, but maybe I can try to do it myself one day ;D

In what part of your code do you process the dbus event for added/removed drives?

from udiskie.

nachoparker avatar nachoparker commented on June 3, 2024

oh!

looks exactly what I was asking for, I didn't see it in udiskie --help, actually just checked again and it is not there.

But yes, looks really good. I'll try it. Maybe the name is not ideal, because not everything you want to trigger is going to be a notification.

People will want to trigger backups, rsyncs, media library rebuilds, notifications and whatnot :)

thanks

from udiskie.

coldfix avatar coldfix commented on June 3, 2024

What udiskie version are you running? The feature is in 1.6.0. If you run udiskie --help it's listed near the bottom before Deprecated options. The example I showed is on the man page.

from udiskie.

nachoparker avatar nachoparker commented on June 3, 2024

yeah, I'm on 1.5.1 on Raspbian Stretch. I used the inotify approach in the end, but it is good that the trigger option is supported ;)

thanks

from udiskie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.