webapp: Automatically install Nautilus integration scripts to get and drop files.
This commit was sponsored by Gian-Maria Daffre.
This commit is contained in:
parent
fb8a32cc7f
commit
f6eb967f1e
6 changed files with 63 additions and 2 deletions
|
@ -35,11 +35,14 @@ standaloneAppBase = getEnv "GIT_ANNEX_APP_BASE"
|
||||||
-
|
-
|
||||||
- Note that this is done every time it's started, so if the user moves
|
- Note that this is done every time it's started, so if the user moves
|
||||||
- it around, the paths this sets up won't break.
|
- it around, the paths this sets up won't break.
|
||||||
|
-
|
||||||
|
- Nautilus hook script installation is done even for packaged apps,
|
||||||
|
- since it has to go into the user's home directory.
|
||||||
-}
|
-}
|
||||||
ensureInstalled :: IO ()
|
ensureInstalled :: IO ()
|
||||||
ensureInstalled = go =<< standaloneAppBase
|
ensureInstalled = go =<< standaloneAppBase
|
||||||
where
|
where
|
||||||
go Nothing = noop
|
go Nothing = installNautilus "git-annex"
|
||||||
go (Just base) = do
|
go (Just base) = do
|
||||||
let program = base </> "git-annex"
|
let program = base </> "git-annex"
|
||||||
programfile <- programFile
|
programfile <- programFile
|
||||||
|
@ -78,6 +81,32 @@ ensureInstalled = go =<< standaloneAppBase
|
||||||
viaTmp writeFile shim content
|
viaTmp writeFile shim content
|
||||||
modifyFileMode shim $ addModes [ownerExecuteMode]
|
modifyFileMode shim $ addModes [ownerExecuteMode]
|
||||||
|
|
||||||
|
installNautilus program
|
||||||
|
|
||||||
|
installNautilus :: FilePath -> IO ()
|
||||||
|
#ifdef linux_HOST_OS
|
||||||
|
installNautilus program = do
|
||||||
|
scriptdir <- (\d -> d </> "nautilus" </> "scripts") <$> userDataDir
|
||||||
|
genscript scriptdir "get"
|
||||||
|
genscript scriptdir "drop"
|
||||||
|
where
|
||||||
|
genscript scriptdir action =
|
||||||
|
installscript (scriptdir </> scriptname action) $ unlines
|
||||||
|
[ "#!/bin/sh"
|
||||||
|
, autoaddedcomment
|
||||||
|
, program ++ " " ++ action ++ " --notify-start --notify-finish \"$@\""
|
||||||
|
]
|
||||||
|
scriptname action = "git-annex " ++ action
|
||||||
|
installscript f c = whenM (safetoinstallscript f) $ do
|
||||||
|
writeFile f c
|
||||||
|
modifyFileMode f $ addModes [ownerExecuteMode]
|
||||||
|
safetoinstallscript f = catchDefaultIO True $
|
||||||
|
elem autoaddedcomment . lines <$> readFileStrict f
|
||||||
|
autoaddedcomment = "# Automatically added by git-annex, do not edit. (To disable, chmod 600 this file.)"
|
||||||
|
#else
|
||||||
|
installNautilus _ = noop
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Returns a cleaned up environment that lacks settings used to make the
|
{- Returns a cleaned up environment that lacks settings used to make the
|
||||||
- standalone builds use their bundled libraries and programs.
|
- standalone builds use their bundled libraries and programs.
|
||||||
- Useful when calling programs not included in the standalone builds.
|
- Useful when calling programs not included in the standalone builds.
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -7,6 +7,8 @@ git-annex (5.20140321) UNRELEASED; urgency=medium
|
||||||
(using the dbus Desktop Notifications Specification)
|
(using the dbus Desktop Notifications Specification)
|
||||||
* --notify-start switch will show desktop notifications when each
|
* --notify-start switch will show desktop notifications when each
|
||||||
file upload/download starts.
|
file upload/download starts.
|
||||||
|
* webapp: Automatically install Nautilus integration scripts
|
||||||
|
to get and drop files.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400
|
-- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400
|
||||||
|
|
||||||
|
|
BIN
doc/assistant/downloadnotification.png
Normal file
BIN
doc/assistant/downloadnotification.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
doc/assistant/nautilusmenu.png
Normal file
BIN
doc/assistant/nautilusmenu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
|
@ -11,4 +11,3 @@ designed to interoperate with it.
|
||||||
utility, with a `-A` switch that enables git-annex support.
|
utility, with a `-A` switch that enables git-annex support.
|
||||||
* Emacs Org mode can auto-commit attached files to git-annex.
|
* Emacs Org mode can auto-commit attached files to git-annex.
|
||||||
* [git annex darktable integration](https://github.com/xxv/darktable-git-annex)
|
* [git annex darktable integration](https://github.com/xxv/darktable-git-annex)
|
||||||
* [Nautilus file manager ingegration](https://gist.github.com/ion1/9660286)
|
|
||||||
|
|
31
doc/tips/file_manager_integration.mdwn
Normal file
31
doc/tips/file_manager_integration.mdwn
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
Integrating git-annex and your file manager provides an easy way to select
|
||||||
|
annexed files to get or drop.
|
||||||
|
|
||||||
|
## nautilus
|
||||||
|
|
||||||
|
Recent git-annex comes with built-in nautilus integration. Just pick the
|
||||||
|
action from the menu.
|
||||||
|
|
||||||
|
[[!img assistant/nautilusmenu.png]]
|
||||||
|
|
||||||
|
[[!img assistant/downloadnotification.png]]
|
||||||
|
|
||||||
|
This is set up by making simple scripts in
|
||||||
|
`~/.local/share/nautilus/scripts`, with names like "git-annex get"
|
||||||
|
|
||||||
|
## your file manager here
|
||||||
|
|
||||||
|
Edit this page and add instructions!
|
||||||
|
|
||||||
|
## general
|
||||||
|
|
||||||
|
If your file manager can run a command on a file, it should be easy to
|
||||||
|
integrate git-annex with it. A simple script will suffice:
|
||||||
|
|
||||||
|
#!/bun/sh
|
||||||
|
git-annex get --notify-start --notify-finish "$@"
|
||||||
|
|
||||||
|
The --notify-start and --notify-stop options make git-annex display a
|
||||||
|
desktop notification. This is useful to give the user an indication that
|
||||||
|
their action took effect. Desktop notifications are currently only
|
||||||
|
implenented for Linux.
|
Loading…
Reference in a new issue