diff --git a/meson.build b/meson.build index 19c03a8..c747e02 100644 --- a/meson.build +++ b/meson.build @@ -8,6 +8,8 @@ project( go_md2man = find_program('go-md2man') shellcheck = find_program('shellcheck', required: false) +profiledir = get_option('profile_dir') + systemd_dep = dependency('systemd') tmpfilesdir = systemd_dep.get_pkgconfig_variable('tmpfilesdir') @@ -24,3 +26,4 @@ install_data( subdir('data') subdir('doc') +subdir('profile.d') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..fe9f410 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option( + 'profile_dir', + description: 'Directory for profile.d files to be read by the shell on start-up', + type: 'string', + value: '/usr/share/profile.d' +) diff --git a/profile.d/meson.build b/profile.d/meson.build new file mode 100644 index 0000000..03b242c --- /dev/null +++ b/profile.d/meson.build @@ -0,0 +1,10 @@ +toolbox_sh = files('toolbox.sh') + +if shellcheck.found() + test('shellcheck profile.d', shellcheck, args: ['--shell=sh', toolbox_sh]) +endif + +install_data( + toolbox_sh, + install_dir: profiledir, +) diff --git a/profile.d/toolbox.sh b/profile.d/toolbox.sh new file mode 100644 index 0000000..da8cc1a --- /dev/null +++ b/profile.d/toolbox.sh @@ -0,0 +1,26 @@ +[ "$BASH_VERSION" != "" ] || [ "$ZSH_VERSION" != "" ] || return 0 +[ "$PS1" != "" ] || return 0 + +toolbox_config="$HOME/.config/toolbox" +host_welcome_stub="$toolbox_config/host-welcome-shown" + +if [ -f /run/ostree-booted ] \ + && ! [ -f "$host_welcome_stub" ]; then + echo "" + echo "Welcome to Fedora Silverblue. This terminal is running on the" + echo "immutable host system. You may want to try out the Toolbox for a" + echo "more traditional environment that allows package installation" + echo "with DNF." + echo "" + printf "For more information, see the " + # shellcheck disable=SC1003 + printf '\033]8;;https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/\033\\documentation\033]8;;\033\\' + printf ".\n" + echo "" + + mkdir -p "$toolbox_config" + touch "$host_welcome_stub" +fi + +unset toolbox_config +unset host_welcome_stub