assistant: Use udisks2 dbus events to detect when disks are mounted, instead of relying on gnome/kde stuff that is not stable.
This commit is contained in:
parent
93806b0c8c
commit
8c3d302532
4 changed files with 27 additions and 31 deletions
|
@ -48,7 +48,7 @@ mountWatcherThread urlrenderer = namedThread "MountWatcher" $
|
||||||
dbusThread :: UrlRenderer -> Assistant ()
|
dbusThread :: UrlRenderer -> Assistant ()
|
||||||
dbusThread urlrenderer = do
|
dbusThread urlrenderer = do
|
||||||
runclient <- asIO1 go
|
runclient <- asIO1 go
|
||||||
r <- liftIO $ E.try $ runClient getSessionAddress runclient
|
r <- liftIO $ E.try $ runClient getSystemAddress runclient
|
||||||
either onerr (const noop) r
|
either onerr (const noop) r
|
||||||
where
|
where
|
||||||
go client = ifM (checkMountMonitor client)
|
go client = ifM (checkMountMonitor client)
|
||||||
|
@ -71,11 +71,6 @@ dbusThread urlrenderer = do
|
||||||
)
|
)
|
||||||
onerr :: E.SomeException -> Assistant ()
|
onerr :: E.SomeException -> Assistant ()
|
||||||
onerr e = do
|
onerr e = do
|
||||||
{- If the session dbus fails, the user probably
|
|
||||||
- logged out of their desktop. Even if they log
|
|
||||||
- back in, we won't have access to the dbus
|
|
||||||
- session key, so polling is the best that can be
|
|
||||||
- done in this situation. -}
|
|
||||||
liftAnnex $
|
liftAnnex $
|
||||||
warning $ "dbus failed; falling back to mtab polling (" ++ show e ++ ")"
|
warning $ "dbus failed; falling back to mtab polling (" ++ show e ++ ")"
|
||||||
pollingThread urlrenderer
|
pollingThread urlrenderer
|
||||||
|
@ -95,12 +90,9 @@ checkMountMonitor client = do
|
||||||
]
|
]
|
||||||
return True
|
return True
|
||||||
where
|
where
|
||||||
startableservices = [gvfsnew, gvfs, gvfsgdu]
|
startableservices = [udisks2]
|
||||||
usableservices = startableservices ++ [kde]
|
usableservices = startableservices
|
||||||
gvfs = "org.gtk.Private.UDisks2VolumeMonitor"
|
udisks2 = "org.freedesktop.UDisks2"
|
||||||
gvfsnew = "org.gtk.vfs.UDisks2VolumeMonitor"
|
|
||||||
gvfsgdu = "org.gtk.Private.GduVolumeMonitor"
|
|
||||||
kde = "org.kde.DeviceNotifications"
|
|
||||||
|
|
||||||
startOneService :: Client -> [ServiceName] -> Assistant Bool
|
startOneService :: Client -> [ServiceName] -> Assistant Bool
|
||||||
startOneService _ [] = return False
|
startOneService _ [] = return False
|
||||||
|
@ -119,27 +111,18 @@ startOneService client (x:xs) = do
|
||||||
|
|
||||||
{- Filter matching events recieved when drives are mounted and unmounted. -}
|
{- Filter matching events recieved when drives are mounted and unmounted. -}
|
||||||
mountChanged :: [MatchRule]
|
mountChanged :: [MatchRule]
|
||||||
mountChanged = [gvfs True, gvfs False, kde, kdefallback]
|
mountChanged = [udisks2mount, udisks2umount]
|
||||||
where
|
where
|
||||||
{- gvfs reliably generates this event whenever a
|
udisks2mount = matchAny
|
||||||
- drive is mounted/unmounted, whether automatically, or manually -}
|
{ matchPath = Just "/org/freedesktop/UDisks2"
|
||||||
gvfs mount = matchAny
|
, matchInterface = Just "org.freedesktop.DBus.ObjectManager"
|
||||||
{ matchInterface = Just "org.gtk.Private.RemoteVolumeMonitor"
|
, matchMember = Just "InterfacesAdded"
|
||||||
, matchMember = Just $ if mount then "MountAdded" else "MountRemoved"
|
|
||||||
}
|
}
|
||||||
{- This event fires when KDE prompts the user what to do with a drive,
|
udisks2umount = matchAny
|
||||||
- but maybe not at other times. And it's not received -}
|
{ matchPath = Just "/org/freedesktop/UDisks2"
|
||||||
kde = matchAny
|
, matchInterface = Just "org.freedesktop.DBus.ObjectManager"
|
||||||
{ matchInterface = Just "org.kde.Solid.Device"
|
, matchMember = Just "InterfacesRemoved"
|
||||||
, matchMember = Just "setupDone"
|
|
||||||
}
|
}
|
||||||
{- This event may not be closely related to mounting a drive, but it's
|
|
||||||
- observed reliably when a drive gets mounted or unmounted. -}
|
|
||||||
kdefallback = matchAny
|
|
||||||
{ matchInterface = Just "org.kde.KDirNotify"
|
|
||||||
, matchMember = Just "enteredDirectory"
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pollingThread :: UrlRenderer -> Assistant ()
|
pollingThread :: UrlRenderer -> Assistant ()
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -13,7 +13,8 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
|
||||||
* registerurl: Check if a remote claims the url, same as addurl does.
|
* registerurl: Check if a remote claims the url, same as addurl does.
|
||||||
* Bug fix: Git config settings passed to git-annex -c did not always take
|
* Bug fix: Git config settings passed to git-annex -c did not always take
|
||||||
effect.
|
effect.
|
||||||
* assistant: Added new name used for udisks2 dbus service in gnome 3.18.
|
* assistant: Use udisks2 dbus events to detect when disks are mounted,
|
||||||
|
instead of relying on gnome/kde stuff that is not stable.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
||||||
|
|
||||||
|
|
|
@ -178,3 +178,5 @@ node /org/gtk/Private/RemoteVolumeMonitor {
|
||||||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||||
|
|
||||||
Works fine in general.
|
Works fine in general.
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 3"""
|
||||||
|
date="2016-01-22T20:10:01Z"
|
||||||
|
content="""
|
||||||
|
Thanks for the info.
|
||||||
|
|
||||||
|
I think I was having difficulty matching on the udisks2 signals before, due
|
||||||
|
to how they're structured, but I found a way now.
|
||||||
|
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue