Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XDG config folder instead of .shutter stray folder #492

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions bin/shutter
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ my $so = Shutter::App::Options->new($sc, $shf);
#set home
#--------------------------------------
$ENV{'HOME'} = Shutter::App::Directories::get_home_dir();
$ENV{'CONFIG'} = Shutter::App::Directories::get_config_dir();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be in the process environment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not needed. I'll drop it.


#--------------------------------------

Expand Down Expand Up @@ -892,7 +893,7 @@ sub STARTUP {
my $combobox_settings_profiles = Gtk3::ComboBoxText->new;
my @current_profiles;
my $current_index = 0;
foreach my $pfile (sort bsd_glob("$ENV{'HOME'}/.shutter/profiles/*.xml")) {
foreach my $pfile (sort bsd_glob("$ENV{'CONFIG'}/shutter/profiles/*.xml")) {
utf8::decode $pfile;
next
if $pfile =~ /\_accounts.xml/; #accounts file - we are looking for "real" profiles
Expand Down Expand Up @@ -2758,7 +2759,7 @@ sub STARTUP {

#load saved settings
#--------------------------------------
my $folder_to_save = $settings_xml->{'general'}->{'folder'} || $ENV{'HOME'};
my $folder_to_save = $settings_xml->{'general'}->{'folder'} || $ENV{'CONFIG'};
my ($cmdname, $extra) = $sc->get_start_with;
if ($cmdname && $folder_to_save) {
evt_take_screenshot('global_keybinding', $cmdname, $folder_to_save, $extra);
Expand Down Expand Up @@ -3879,11 +3880,11 @@ sub STARTUP {
if ($combobox_settings_profiles->get_active_text) {
my $active_text = $combobox_settings_profiles->get_active_text;
my $active_index = $combobox_settings_profiles->get_active;
unlink("$ENV{'HOME'}/.shutter/profiles/" . $active_text . ".xml");
unlink("$ENV{'HOME'}/.shutter/profiles/" . $active_text . "_accounts.xml");
unlink("$ENV{'CONFIG'}/shutter/profiles/" . $active_text . ".xml");
unlink("$ENV{'CONFIG'}/shutter/profiles/" . $active_text . "_accounts.xml");

unless ($shf->file_exists("$ENV{'HOME'}/.shutter/profiles/" . $active_text . ".xml")
|| $shf->file_exists("$ENV{'HOME'}/.shutter/profiles/" . $active_text . "_accounts.xml"))
unless ($shf->file_exists("$ENV{'CONFIG'}/shutter/profiles/" . $active_text . ".xml")
|| $shf->file_exists("$ENV{'CONFIG'}/shutter/profiles/" . $active_text . "_accounts.xml"))
{
$combobox_settings_profiles->remove_text($active_index);
$combobox_settings_profiles->set_active($combobox_settings_profiles->get_active + 1);
Expand Down Expand Up @@ -7900,7 +7901,7 @@ sub STARTUP {
$current_plugin->set_line_wrap(TRUE);
$plugin_dialog->get_child->add($current_plugin);

my @plugin_paths = ("$shutter_root/share/shutter/resources/system/plugins/*/*", "$ENV{'HOME'}/.shutter/plugins/*/*");
my @plugin_paths = ("$shutter_root/share/shutter/resources/system/plugins/*/*", "$ENV{'CONFIG'}/shutter/plugins/*/*");

#fallback icon
# maybe the plugin
Expand Down Expand Up @@ -10773,7 +10774,7 @@ sub STARTUP {
if ($profile_response eq 'accept') {
my $entered_name = $new_profile_name->get_text;

if ($shf->file_exists("$ENV{'HOME'}/.shutter/profiles/$entered_name.xml")) {
if ($shf->file_exists("$ENV{'CONFIG'}/shutter/profiles/$entered_name.xml")) {

#ask the user to replace the profile
#replace button
Expand Down
13 changes: 6 additions & 7 deletions share/shutter/resources/modules/Shutter/App/Directories.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ use warnings;
use Glib qw/ TRUE /;

use constant {
SHUTTER_DIR => "shutter",
UNSAVED_DIR => "unsaved",
TEMP_DIR => "temp",
AUTOSTART_DIR => "autostart",
HIDDEN_SHUTTER_DIR => ".shutter",
PROFILES_DIR => "profiles"
SHUTTER_DIR => "shutter",
UNSAVED_DIR => "unsaved",
TEMP_DIR => "temp",
AUTOSTART_DIR => "autostart",
PROFILES_DIR => "profiles"
};

sub create_if_not_exists {
Expand Down Expand Up @@ -66,7 +65,7 @@ sub get_home_dir {Glib::get_home_dir}
sub get_config_dir {Glib::get_user_config_dir}

sub create_hidden_home_dir_if_not_exist {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function name doesn't reflect anymore what this function does, as the shutter dir is not longer "hidden", and not necessary in home

my $hidden_dir = $ENV{HOME} . "/" . HIDDEN_SHUTTER_DIR;
my $hidden_dir = Glib::get_user_config_dir . "/" . SHUTTER_DIR;
my $hidden_profiles_dir = "$hidden_dir" . "/" . PROFILES_DIR;

mkdir $hidden_dir unless -d $hidden_dir;
Expand Down
3 changes: 2 additions & 1 deletion t/Shutter/App/02_directories.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require_ok("Shutter::App::Directories");
# do not pollute /home with these tests
my $local_home = tempdir( CLEANUP => 1 );
local $ENV{HOME} = $local_home;
local $ENV{CONFIG} = $local_home . "/.config";

subtest "create_if_not_exists" => sub {
my $dir = tempdir( CLEANUP => 1 ) . "/foo";
Expand Down Expand Up @@ -72,7 +73,7 @@ require_ok("Shutter::App::Directories");
};

subtest "create_hidden_home_dir_if_not_exist" => sub {
my $hidden_dir = $ENV{HOME} . "/" . Shutter::App::Directories->HIDDEN_SHUTTER_DIR;
my $hidden_dir = $ENV{CONFIG} . "/" . Shutter::App::Directories->SHUTTER_DIR;
my $profiles_dir = $hidden_dir . "/" . Shutter::App::Directories->PROFILES_DIR;

ok( !-d $hidden_dir, "hidden dir doesn't exist" );
Expand Down