Comments (9)
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.
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.
I'll look in the udisk api, then :)
from udiskie.
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.
Great, you found your own solution. Unless you want further advice, you can close the issue (or I'll do it).
from udiskie.
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.
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.
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.
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)
- Tell daemon to pause automounting HOT 1
- Tray menu shows invalid entry on first launch and icons are hard to see HOT 1
- Unmounting Btrfs partition: Error finding object for block device
- shell completions: need to escape spaces in labels HOT 2
- Not showing "internal HDD" HOT 1
- When use together with `tomb`, it cause problem because of the loop device password prompt. HOT 1
- make appimage or static binary file HOT 1
- Not authorized to mount on Linux Mint HOT 1
- Hide unpower (at least for optical devices) HOT 2
- Fedora package is wrong name on the installation manual HOT 1
- Why does the polkit rule grants permission to users in storage group? HOT 2
- Flat menu style not working HOT 2
- python messages about dbus.py and udisks2.py HOT 6
- Kobo Libra H2O e-reader does not get auto-mounted when connected via USB HOT 8
- Wrong location for bash completions. HOT 1
- Breaks in Python 3.12 due to dependency on distutils HOT 1
- notification_command should be renamed HOT 6
- ValueError: Namespace Gio not available on startup HOT 2
- The --terminal command-line option does nothing. HOT 1
- Run command after automount HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from udiskie.