I am trying to make a Elementary OS app that I need to get user home folder. I tried GLib.Environment.get_home_dir ()
and Granite.Services.Paths.home_folder.get_path ()
but they both return null
. What is the proper way to get user's home folder for Elementary OS?
2 Answers
Granite.Services.Paths
is now deprecated and uses GLib.Environment.get_home_dir ()
internally anyway.
If GLib.Environment.get_home_dir ()
is returning null
, I believe there is probably something wrong with your setup/install as this method works on my system.
I believe it uses the HOME
environment variable, so check this is set and isn't being overwritten by something else.
This works for me:
xdg_path = new Granite.Services.Paths();
app_xdg_path.initialize (Constants.bookworm_id, Constants.INSTALL_SCRIPTS_DIR);
bookworm_config_path = app_xdg_path.user_data_folder.get_path();
Are you missing the initialize step