diff --git a/AUTHORS b/AUTHORS index eee16bb32..5fa5205cf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -303,3 +303,4 @@ suggestions: bjonnh OKOMper eldios + Eli diff --git a/ChangeLog b/ChangeLog index a48df6064..99061de8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,8 @@ (thanks to E. Manuel Cerr'on Angeles) - TW-1857 Change Task::get call to the more efficient Task::has (thanks to Zachary Manning). +- TW-1873 Specify different path to extensions/hooks directory + (thanks to Eli). - Added 'juhannus' as a synonym for 'midsommarafton' (thanks to Lynoure Braakman). - Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY' diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 28c149701..3a708e496 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -180,6 +180,10 @@ shell meta character, which will be properly expanded. Note that the TASKDATA environment variable overrides this setting. +.TP +.B hooks.location=$HOME/.task/hooks +This is a path to the hook scripts directory. By default it is ~/.task/hooks. + .TP .B locking=1 Determines whether to use file locking when accessing the pending.data and diff --git a/src/Config.cpp b/src/Config.cpp index 6d904e5d8..7969b90fe 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -532,7 +532,11 @@ void Config::createDefaultData (const std::string& data) d.create (); - d += "hooks"; + if (has ("hooks.location")) + d = Directory (get ("hooks.location")); + else + d += "hooks"; + d.create (); } } diff --git a/src/Hooks.cpp b/src/Hooks.cpp index f779b6b59..1ef6abbde 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -54,9 +54,19 @@ void Hooks::initialize () { _debug = context.config.getInteger ("debug.hooks"); - // Scan /hooks - Directory d (context.config.get ("data.location")); - d += "hooks"; + // Scan + // /hooks + Directory d; + if (context.config.has ("hooks.location")) + { + d = Directory (context.config.get ("hooks.location")); + } + else + { + d = Directory (context.config.get ("data.location")); + d += "hooks"; + } + if (d.is_directory () && d.readable ()) { diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 15362bf99..0e9789f64 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -307,8 +307,16 @@ int CmdDiagnostics::execute (std::string& output) << "\n\n"; // Display hook status. - Path hookLocation (context.config.get ("data.location")); - hookLocation += "hooks"; + Path hookLocation; + if (context.config.has ("hooks.location")) + { + hookLocation = Path (context.config.get ("hooks.location")); + } + else + { + hookLocation = Path (context.config.get ("data.location")); + hookLocation += "hooks"; + } out << bold.colorize (STRING_CMD_DIAG_HOOKS) << '\n'