Meanwhile I have found a simpler solution, which should also continue to
work with GnuCash 5.x.
I have created a script named "z-gnucash-update.sh" in
"/etc/profile.d/", containing:
flatpak run --command=gnucash-cli org.gnucash.GnuCash --quotes get <path
to GnuCash data file>
The script name begins with "z" to ensure that it runs *after* all other
scripts in "/etc/profile.d/".
It runs *for any user* at login *after* user authorization. This is
important in my case because my GnuCash data file is on a network file
share needing user authorization.
The key advantage of doing it this way (as opposed e.g. to using cron or
crontab) is that the script gets executed *before* the user's GUI
session starts.
This means that there cannot be any competition between the update
script and an interactive GnuCash session for access to the GnuCash data
file.
I have only tested this in Ubuntu Studio 22.04 LTS, but see no reason
why this approach shouldn't work in any Ubuntu variant.
If any of you can confirm that it works in other variants, I will add a
decription to the wiki.
Thanks to all for your advice and support!
On 05.12.22 20:50, john wrote:
Get it working before worrying about the rest. First make sure that
the hook is firing by adding a print statement to the lambda,
something like
(gnc-hook-add-scm-dangler HOOK-UI-POST-STARTUP
(lambda ()
(format #t "Retrieving Quotes~%")
(gnc:book-add-quotes #f (gnc-get-current-book)))
You'll need to run GnuCash from a terminal session with `flatpak run
org.gnucash.GnuCash` to see the output. You might want to add
--logto=stderr to that so that you'll see the results of the perl and
FQ checks to make sure that that's not the problem.
Regards,
John Ralls
On Dec 5, 2022, at 2:31 AM, rsbrux <rsb...@yahoo.com> wrote:
A little further study suggests that I should have placed
config-user.scm in GNC_CONFIG_HOME (in my case
$HOME/.var/app/org.gnucash.GnuCash/config/gnucash/) instead of
GNC_DATA_HOME (see
https://wiki.gnucash.org/wiki/Configuration_Locations#In_GNC_CONFIG_HOME).
However, moving it there still did not have the desired effect (i.e.
no new prices appeared in GC's Price DB, even after leaving GC open
for a quarter hour). It occurred to me that this could be caused by
inadequate privileges, but changing the privileges of config-user.scm
to 775 (and restarting GC) still did not result in any new price quotes.
As previously mentioned I would like this behaviour to be
user-independent. It appears that I should be able to achieve this
by redirecting GNC_CONFIG_HOME to a common direct by means of
environment variable. However, the pages
https://wiki.gnucash.org/wiki/Configuration_Locations and
https://wiki.gnucash.org/wiki/Environment_Variables disagree on the
names of the environment variables.
On 28.11.22 08:53, rsbrux wrote:
Of course.
Sent from my iPad
On 27 Nov 2022, at 22:41, John Ralls <jra...@ceridwen.us> wrote:
Did you restart GnuCash?
Regards,
John Ralls
On Nov 27, 2022, at 11:07 AM, rsbrux <rsb...@yahoo.com> wrote:
P.S. I created the file
$HOME/.var/app/org.gnucash.GnuCash/data/gnucash/config-user.scm
with the contents:
(gnc-hook-add-scm-dangler HOOK-UI-POST-STARTUP
(lambda () (gnc:book-add-quotes #f (gnc-get-current-book)))
under my own Ubuntu login, but the price database does not show
any new prices when I open GC and let it sit for half an hour.
Thanks for your help.
On 27.11.22 18:35, rsbrux wrote:
Thanks, that sounds very promising! My only problem is that I
have a Flatpak installation under Ubuntu.
According to
https://code.gnucash.org/wiki/Configuration_Locations#GNC_DATA_HOME,
GNC_DATA_HOME is under $HOME.
However, I have installed GC for all users on the system and want
the startup task to run regardless of who is running GC.
If I put config-user.scm in
$HOME/.var/app/org.gnucash.GnuCash/data/gnucash, won't it be
user-specific?
On 25.11.22 21:07, john wrote:
On Nov 25, 2022, at 12:56 AM, rsbrux via gnucash-user
<gnucash-user@gnucash.org>
wrote:
I used to have a chron job set up to automatically fetch
security prices on first login each day, but found this
inconvenient because it locks the data file, and opening
GnuCash is often the first thing I do upon logging in.
I have noticed that when I have GC open interactively, I can
start an update in the price database window and let it run in
the background while I continue to work in the registers.
Would there be some way to get GC to perform the Price Database
automatically when GC is started (interactively), instead of
performing the automatic price update in a separate session?
Yes, but only through 4.x because the quotes system won't be
accessible from Scheme in GnuCash 5, it having been rewritten in
C++.
Create if necessary $GNC_DATA_HOME/config-user.scm and edit it
to add
(gnc-hook-add-scm-dangler HOOK-UI-POST-STARTUP
(lambda () (gnc:book-add-quotes #f (gnc-get-current-book)))
Regards,
John Ralls
_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.