diff --git a/kdesrc-build b/kdesrc-build index b1915bb..25763fd 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -6686,16 +6686,19 @@ sub installCustomSessionDriver return; } - installCustomFile($ctx, $envScript, "$ENV{HOME}/.kde-env-master.sh", + my $destDir = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config"; + super_mkdir($destDir) unless -d $destDir; + + installCustomFile($ctx, $envScript, "$destDir/kde-env-master.sh", 'kde-env-master-digest'); installCustomFile($ctx, $sessionScript, "$ENV{HOME}/.xsession", 'xsession-digest'); if (!pretending()) { - if (! -e "$ENV{HOME}/.kde-env-user.sh") { - copy($userSample, "$ENV{HOME}/.kde-env-user.sh") or do { + if (! -e "$destDir/kde-env-user.sh") { + copy($userSample, "$destDir/kde-env-user.sh") or do { warning ("b[*] Unable to install b[$userSample]: $!"); - warning ("b[*] You should create b[~/.kde-env-user.sh] yourself or fix the error and re-run"); + warning ("b[*] You should create b[~/.config/kde-env-user.sh] yourself or fix the error and re-run"); }; } diff --git a/kdesrc-build-test.pl b/kdesrc-build-test.pl index 56e5007..b299961 100755 --- a/kdesrc-build-test.pl +++ b/kdesrc-build-test.pl @@ -517,36 +517,37 @@ SKIP: { like ($newQMakePossibility, qr/^qmake/, 'qmake looks like an executable even in scalar context.'); } -# This test set must be run first as xsession depends on this env-master. -is(system('/bin/sh', '-n', "$RealBin/sample-kde-env-master.sh"), 0, - 'env-master pre-install syntax check'); +do { + local $ENV{HOME} = "$testSourceDirName"; # Search right spot for kde-env-master.sh + local $ENV{XDG_CONFIG_HOME} = $testSourceDirName; -$ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run. + # This test set must be run first as xsession depends on this env-master. + is(system('/bin/sh', '-n', "$RealBin/sample-kde-env-master.sh"), 0, + 'env-master pre-install syntax check'); -is(system('/bin/sh', '-u', "$RealBin/sample-kde-env-master.sh"), 0, - 'env-master unset variable check'); + local $ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run. -# Deliberately after env-master, env-master should have no unset variables if user doesn't set -# this up. -ok(File::Copy::copy("$RealBin/sample-kde-env-user.sh", "$testSourceDirName/.kde-env-user.sh"), - 'env-user sample installation'); + is(system('/bin/sh', '-u', "$RealBin/sample-kde-env-master.sh"), 0, + 'env-master unset variable check'); -# Ensure this function can run without throwing exception. -ok(installTemplatedFile("$RealBin/sample-kde-env-master.sh", "$testSourceDirName/.kde-env-master.sh", $ctx) || 1, - 'env-master template installation'); + # Deliberately after env-master, env-master should have no unset variables if user doesn't set + # this up. + ok(File::Copy::copy("$RealBin/sample-kde-env-user.sh", "$testSourceDirName/kde-env-user.sh"), + 'env-user sample installation'); -is(system('/bin/sh', '-n', "$RealBin/sample-xsession.sh"), 0, - 'xsession pre-install syntax check'); + # Ensure this function can run without throwing exception. + ok(installTemplatedFile("$RealBin/sample-kde-env-master.sh", "$testSourceDirName/kde-env-master.sh", $ctx) || 1, + 'env-master template installation'); -ok(File::Copy::copy("$RealBin/sample-xsession.sh", "$testSourceDirName/xsession.sh"), - 'xsession installation'); + is(system('/bin/sh', '-n', "$RealBin/sample-xsession.sh"), 0, + 'xsession pre-install syntax check'); -$ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run. -is(system('/bin/sh', '-u', "$RealBin/sample-xsession.sh"), 0, - 'xsession unset variable check'); + ok(File::Copy::copy("$RealBin/sample-xsession.sh", "$testSourceDirName/xsession.sh"), + 'xsession installation'); + + is(system('/bin/sh', '-u', "$RealBin/sample-xsession.sh"), 0, + 'xsession unset variable check'); -do { - local $ENV{HOME} = "$testSourceDirName"; # Search right spot for kde-env-master.sh is(system('/bin/sh', '-n', "$testSourceDirName/xsession.sh"), 0, 'xsession post-install syntax check'); }; diff --git a/sample-kde-env-master.sh b/sample-kde-env-master.sh index 532d70d..7990a9f 100644 --- a/sample-kde-env-master.sh +++ b/sample-kde-env-master.sh @@ -9,16 +9,18 @@ # # See also the sample xsession setup script which requires this file. # -# Use by copying this script to ~/.kde-env-master (this will be done for you by -# kdesrc-build and/or kdesrc-build-setup, later). +# Use by copying this script to $XDG_CONFIG_HOME/kde-env-master.sh (this will +# be done for you by kdesrc-build and/or kdesrc-build-setup, later). 99% of the +# time this means ~/.config/kde-env-master.sh # # NOTHING IN THIS FILE IS MODIFIABLE, OTHERWISE WARNINGS WILL BE GENERATED # === Load user environment settings (i.e. not set through kdesrc-buildrc) +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" # ALL USER MODS GO HERE ↴ -if test -f "$HOME/.kde-env-user.sh"; then - . "$HOME/.kde-env-user.sh" +if test -f "$XDG_CONFIG_HOME/kde-env-user.sh"; then + . "$XDG_CONFIG_HOME/kde-env-user.sh" fi # === Modifiable variables. Should be set automatically by kdesrc-build based diff --git a/sample-kde-env-user.sh b/sample-kde-env-user.sh index 07c42d4..50c6f05 100644 --- a/sample-kde-env-user.sh +++ b/sample-kde-env-user.sh @@ -4,7 +4,9 @@ # setup files, this one can be modified by the user, and kdesrc-build will not # warn about it or overwrite it. # -# This file should be installed to ~/.kde-env-user.sh +# This file should be installed to $XDG_CONFIG_HOME/kde-env-user.sh (which +# normally means ~/.config/kde-env-user.sh) +# # As long as it is found here, the kdesrc-build sample session and environment # setup scripts will pull in settings from that file first. diff --git a/sample-xsession.sh b/sample-xsession.sh index 4b8f768..8ac8473 100644 --- a/sample-xsession.sh +++ b/sample-xsession.sh @@ -12,7 +12,9 @@ # .xsession-local, which will be sourced just prior to running KDE. This can # read .bashrc, just set a few vars, etc. -. "$HOME/.kde-env-master.sh" # Should be installed by kdesrc-build +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" + +. "${XDG_CONFIG_HOME}/kde-env-master.sh" # Should be installed by kdesrc-build # See .kde-env-master.sh for details on the kdesrc-build: filter stuff