From 69c14a2429aeb80b7bc01c9b875d7114450e4e72 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Wed, 10 Jul 2024 14:31:27 +0200 Subject: [PATCH] feat: enable all optional shellcheck validations --- files/dom0/.local/bin/dom0/qvm-stats | 43 +++--- files/dom0/.local/bin/dom0/xfce-xkb-global | 2 +- files/git/.config/git/shell/.git-shell-lib | 22 +-- files/git/.config/git/shell/description | 18 +-- files/git/.config/git/shell/help | 6 +- files/git/.config/git/shell/init | 12 +- files/git/.config/git/shell/list | 18 +-- .../git/template/hooks/pre-receive.sample | 121 ++++++++-------- .../git/template/hooks/prepare-commit-msg | 16 +-- files/git/.local/bin/git-client-setup | 22 +-- files/git/.local/bin/git-pager | 4 +- files/git/.local/bin/git-server-setup | 25 ++-- files/net/.config/sh/profile.d/net.sh | 6 +- files/qvm-copy-dotfiles | 30 ++-- files/setup.sh | 36 +++-- files/sh/.config/bash/bash_env | 4 +- files/sh/.config/bash/bash_profile | 7 +- files/sh/.config/bash/bashrc | 41 ++++-- files/sh/.config/less/lessfilter | 1 + files/sh/.config/sh/profile | 129 +++++++++--------- files/sh/.config/sh/shrc | 86 +++++++----- files/sh/.local/bin/get-script-dir | 12 +- files/sh/.local/bin/gpg-sign-email | 8 +- files/sh/.local/bin/has | 2 + files/sh/.local/bin/requires-root | 5 +- files/sh/.local/bin/resize-terminal | 7 +- files/tmux/.local/bin/ta | 98 ++++++------- files/tmux/.local/bin/tmux-sorcerer | 36 ++--- files/x11/.config/sh/profile.d/x11.sh | 4 +- files/x11/.config/x11/xinitrc | 4 +- files/x11/.config/x11/xprofile | 9 +- files/x11/.config/x11/xsession | 4 +- files/x11/.config/x11/xsessionrc | 4 +- 33 files changed, 461 insertions(+), 381 deletions(-) diff --git a/files/dom0/.local/bin/dom0/qvm-stats b/files/dom0/.local/bin/dom0/qvm-stats index 40bd702..a9b2e88 100755 --- a/files/dom0/.local/bin/dom0/qvm-stats +++ b/files/dom0/.local/bin/dom0/qvm-stats @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-FileCopyrightText: 2018 Chris Laprise -# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. # # SPDX-License-Identifier: GPL-3.0-only @@ -9,6 +9,20 @@ ## Credits: https://github.com/tasket/Qubes-scripts set -eu +if ! command -v sensors >/dev/null; then + echo "Program not installed: sensors" >&2 + exit 1 +fi +if ! command -v xentop >/dev/null; then + echo "Program not installed: xentop" >&2 + exit 1 +fi + +sensors_stats () { + # shellcheck disable=SC2312 + sensors | grep -E "^(${sensor_lines})" +} + delay=5 sortcol=3 sensor_lines='Package id 0|fan1|CPU' @@ -17,38 +31,35 @@ newline=' sumline="--------------------------------------------------------" header="\033[2K\nVM NAME STATE CPU(%) MEM(MB)" -sensors_stats () { - sensors | grep -E "^($sensor_lines)" -} - trap "tput reset" HUP INT QUIT ABRT TERM EXIT tput reset sensors_stats -echo -e "$header" -cpusum=0; memsum=0; table="$sumline" -# shellcheck disable=SC2016 -stdbuf -oL xentop -b -f -d "$delay" | \ +echo -e "${header}" +cpusum=0; memsum=0; table="${sumline}" +# shellcheck disable=SC2016,SC2312 +stdbuf -oL xentop -b -f -d "${delay}" | \ stdbuf -oL awk '{printf ("%-32s %5s %5d %7d\n", $1,$2,$4,$5/1000) }' | \ ( read -r ln while true; do if read -r -t 0.1 ln; then - table="$table$newline$ln" - read -r _ _ cpu mem <<<"$ln" + table="${table}${newline}${ln}" + read -r _ _ cpu mem <<<"${ln}" cpusum=$((cpusum+cpu)) memsum=$((memsum+mem)) else # End of list, print totals, make new page. - sort -k $sortcol -n -r <<<"$table" - printf '%-32s %5s %5d %7d\033[J\033[H' " " " " "$cpusum" "$memsum" + sort -k "${sortcol}" -n -r <<<"${table}" + printf '%-32s %5s %5d %7d\033[J\033[H' " " " " "${cpusum}" \ + "${memsum}" read -r ln cpusum=0; memsum=0 - table="$sumline" + table="${sumline}" #clear - #sensors |grep -E "^($sensor_lines)" + #sensors |grep -E "^(${sensor_lines})" sensors_stats - echo -e "\033[2K$header\n" + echo -e "\033[2K${header}\n" fi done ) diff --git a/files/dom0/.local/bin/dom0/xfce-xkb-global b/files/dom0/.local/bin/dom0/xfce-xkb-global index d0c14a3..682869a 100755 --- a/files/dom0/.local/bin/dom0/xfce-xkb-global +++ b/files/dom0/.local/bin/dom0/xfce-xkb-global @@ -20,4 +20,4 @@ set -eu xkb_plugin="$(xfconf-query -v -c xfce4-panel -p /plugins -l | grep xkb)" -xfconf-query -c xfce4-panel -p "$xkb_plugin/group-policy" -n -s 0 +xfconf-query -c xfce4-panel -p "${xkb_plugin}/group-policy" -n -s 0 diff --git a/files/git/.config/git/shell/.git-shell-lib b/files/git/.config/git/shell/.git-shell-lib index 063b865..f979be9 100755 --- a/files/git/.config/git/shell/.git-shell-lib +++ b/files/git/.config/git/shell/.git-shell-lib @@ -6,7 +6,7 @@ set -eu -## Guarantee commands are run from $HOME +## Guarantee commands are run from ${HOME} cd # shellcheck disable=SC2034 @@ -25,35 +25,35 @@ fail_invalid_name(){ test_description(){ key="$1" value="$2" - if ! (echo "$value" | grep -E -q "${description_regex}"); then - fail_invalid_name "$key" + if ! (echo "${value}" | grep -E -q "${description_regex}"); then + fail_invalid_name "${key}" fi } test_name(){ key="$1" value="$2" - if ! (echo "$value" | grep -E -q "${regex}"); then - fail_invalid_name "$key" + if ! (echo "${value}" | grep -E -q "${regex}"); then + fail_invalid_name "${key}" fi } clean_repo_name(){ case "${repo-}" in *.git) repo="";; - *) repo="$repo.git";; + *) repo="${repo}.git";; esac } is_bare(){ _repo="$1" - if ! test -d "$_repo"; then - echo "Repository doesn't exist: $_repo" >&2 + if ! test -d "${_repo}"; then + echo "Repository doesn't exist: ${_repo}" >&2 return 1 fi - if ! test "$(git -C "$_repo" rev-parse --is-bare-repository)" = "true" - then - echo "Repository is not bare: $_repo" >&2 + bare_repo_check="$(git -C "${_repo}" rev-parse --is-bare-repository)" + if ! test "${bare_repo_check}" = "true"; then + echo "Repository is not bare: ${_repo}" >&2 return 1 fi } diff --git a/files/git/.config/git/shell/description b/files/git/.config/git/shell/description index c9f0489..2e9cfc9 100755 --- a/files/git/.config/git/shell/description +++ b/files/git/.config/git/shell/description @@ -13,29 +13,29 @@ usage(){ # shellcheck disable=2154 echo "usage: ${0##*/} SECTION REPOSITORY [DESCRIPTION] note: prints the current description if none description is specified.:w -regex: $regex" >&2 +regex: ${regex}" >&2 exit 1 } test -n "${2-}" || usage section="$1" -test_name section "$section" +test_name section "${section}" repo="$2" -test_name repo "$repo" +test_name repo "${repo}" clean_repo_name # shellcheck disable=SC2154 -is_bare "$base/$section/$repo" +is_bare "${base}/${section}/${repo}" -description_file="$base/$section/$repo/description" +description_file="${base}/${section}/${repo}/description" if test -z "${3-}"; then - test -f "$description_file" || touch "$description_file" - cat "$description_file" + test -f "${description_file}" || touch "${description_file}" + cat "${description_file}" exit 0 fi description="$(echo "$3" | cut -c 1-80)" -test_description description "$description" +test_description description "${description}" -echo "$description" | tee "$description_file" +echo "${description}" | tee "${description_file}" diff --git a/files/git/.config/git/shell/help b/files/git/.config/git/shell/help index 4693d6e..93ad909 100755 --- a/files/git/.config/git/shell/help +++ b/files/git/.config/git/shell/help @@ -11,8 +11,8 @@ set -eu printf "Available commands:\n" for f in "${0%/*}"/*; do test "${f##*/}" != "help" || continue - test -f "$f" || continue - test -x "$f" || continue - usage="$("$f" --help 2>&1 | head -1 | sed "s/[Uu]sage: //")" + test -f "${f}" || continue + test -x "${f}" || continue + usage="$("${f}" --help 2>&1 | head -1 | sed "s/[Uu]sage: //")" printf ' %-15s\t\t%s\n' "${f##*/}" "${usage}" done diff --git a/files/git/.config/git/shell/init b/files/git/.config/git/shell/init index 8d5b6dc..1abd22d 100755 --- a/files/git/.config/git/shell/init +++ b/files/git/.config/git/shell/init @@ -12,25 +12,25 @@ set -eu usage(){ # shellcheck disable=2154 echo "usage: ${0##*/} SECTION REPOSITORY [BRANCH] -regex: $regex" >&2 +regex: ${regex}" >&2 exit 1 } test -n "${2-}" || usage section="$1" -test_name section "$section" +test_name section "${section}" repo="$2" -test_name repo "$repo" +test_name repo "${repo}" clean_repo_name branch="" test -n "${3-}" && branch="$3" if test -n "${branch}"; then - test_name branch "$branch" + test_name branch "${branch}" fi # shellcheck disable=SC2154 git init \ --bare \ - ${branch:+--initial-branch $branch} \ - -- "$base/$section/$repo" + ${branch:+--initial-branch ${branch}} \ + -- "${base}/${section}/${repo}" diff --git a/files/git/.config/git/shell/list b/files/git/.config/git/shell/list index fd48c34..79f2653 100755 --- a/files/git/.config/git/shell/list +++ b/files/git/.config/git/shell/list @@ -15,7 +15,7 @@ set -eu usage(){ # shellcheck disable=2154 echo "usage: ${0##*/} [SECTION] -regex: $regex" >&2 +regex: ${regex}" >&2 exit 1 } @@ -23,12 +23,12 @@ section="" case "${1-}" in -h|--help) usage;; "") ;; - *) section="$1"; test_name section "$section";; + *) section="$1"; test_name section "${section}";; esac # shellcheck disable=SC2154 -if ! test -d "$base/$section"; then - echo "Section doesn't exist: $section" >&2 +if ! test -d "${base}/${section}"; then + echo "Section doesn't exist: ${section}" >&2 exit 1 fi @@ -39,10 +39,10 @@ print_bare=' ' # shellcheck disable=SC2154 -if test -n "$section"; then - find "$base/$section" -maxdepth 1 -type d -name "*.git" \ - -exec sh -c "$print_bare" -- {} \; -prune 2>/dev/null || true +if test -n "${section}"; then + find "${base}/${section}" -maxdepth 1 -type d -name "*.git" \ + -exec sh -c "${print_bare}" -- {} \; -prune 2>/dev/null || true else - find "$base" -maxdepth 2 -type d -name "*.git" \ - -exec sh -c "$print_bare" -- {} \; -prune 2>/dev/null || true + find "${base}" -maxdepth 2 -type d -name "*.git" \ + -exec sh -c "${print_bare}" -- {} \; -prune 2>/dev/null || true fi diff --git a/files/git/.config/git/template/hooks/pre-receive.sample b/files/git/.config/git/template/hooks/pre-receive.sample index d7267fe..65e8213 100755 --- a/files/git/.config/git/template/hooks/pre-receive.sample +++ b/files/git/.config/git/template/hooks/pre-receive.sample @@ -30,13 +30,18 @@ set -eu command -v git >/dev/null || exit 1 +: "${GIT_PUSH_CERT_STATUS:-}" +: "${GIT_PUSH_CERT_KEY:-}" +: "${GIT_PUSH_CERT_NONCE_STATUS:-}" +: "${GIT_PUSH_CERT_NONCE:-}" + obj_rejected="" zero="$(git hash-object --stdin &2 + echo "${*}" >&2 } require_signed_push(){ @@ -77,33 +82,33 @@ check_signed_push_keyring(){ cert="$(git cat-file blob "${GIT_PUSH_CERT}")" begin_sig="-----BEGIN PGP SIGNATURE-----" - cert_msg="$tmpdir"/cert.msg - cert_sig="$tmpdir"/cert.sig + cert_msg="${tmpdir}"/cert.msg + cert_sig="${tmpdir}"/cert.sig in_sig=0 - echo "$cert" | while read -r line; do - if test "$in_sig" = "1" || test "$line" = "$begin_sig"; then + echo "${cert}" | while read -r line; do + if test "${in_sig}" = "1" || test "${line}" = "${begin_sig}"; then in_sig=1 - echo "$line" | tee -a "$cert_sig" - elif test "$line" != "$begin_sig"; then - echo "$line" | tee -a "$cert_msg" + echo "${line}" | tee -a "${cert_sig}" + elif test "${line}" != "${begin_sig}"; then + echo "${line}" | tee -a "${cert_msg}" else break fi done - gpg_out="$("$gpg" --status-fd=1 --no-default-keyring \ + gpg_out="$("${gpg}" --status-fd=1 --no-default-keyring \ --homedir "${GIT_PUSH_CERT_PGPHOMEDIR}" \ - --verify "$cert_sig" "$cert_msg" 2>&1)" + --verify "${cert_sig}" "${cert_msg}" 2>&1)" gpg_ec="$?" - gpg_sig="$(echo "$gpg_out" | awk '/ GOODSIG /{print $3}')" - if test "$gpg_ec" = "0"; then - true "Cert validation succeeded. Key: $gpg_sig" + gpg_sig="$(echo "${gpg_out}" | awk '/ GOODSIG /{print $3}')" + if test "${gpg_ec}" = "0"; then + true "Cert validation succeeded. Key: ${gpg_sig}" else err "Cert validation failed. Verification output:" - err "$gpg_out" + err "${gpg_out}" fi - rm -rf "$tmpdir" + rm -rf "${tmpdir}" if test "${GIT_PUSH_CERT_NONCE_STATUS}" = "OK"; then true "Cert nonce validation succeeded. Nonce: ${GIT_PUSH_CERT_NONCE}" @@ -119,47 +124,47 @@ if git config --get receive.certNonceSeed >/dev/null 2>&1; then fi while read -r oldrev newrev ref; do - true "$oldrev $newrev $ref" - test "$newrev" = "$zero" && continue + true "${oldrev} ${newrev} ${ref}" + test "${newrev}" = "${zero}" && continue - if test "$oldrev" = "$zero"; then - objects="$(git rev-list "$newrev")" + if test "${oldrev}" = "${zero}"; then + objects="$(git rev-list "${newrev}")" else - objects="$(git rev-list "$oldrev..$newrev")" + objects="$(git rev-list "${oldrev}..${newrev}")" fi - obj_type="$(git cat-file -t "$newrev")" - if test "$obj_type" = "tag"; then - if git verify-tag "$newrev" >/dev/null 2>&1; then - true "Tag validation succeeded for tag: $newrev" + obj_type="$(git cat-file -t "${newrev}")" + if test "${obj_type}" = "tag"; then + if git verify-tag "${newrev}" >/dev/null 2>&1; then + true "Tag validation succeeded for tag: ${newrev}" else - obj_rejected="${obj_rejected-} $newrev " + obj_rejected="${obj_rejected-} ${newrev} " continue fi - commit_tag="$(git rev-list -n1 "$newrev")" - obj_rejected="$(echo "$obj_rejected" | sed "s/ $commit_tag //")" - err "Commit validation done by tag: $commit_tag $newrev" + commit_tag="$(git rev-list -n1 "${newrev}")" + obj_rejected="$(echo "${obj_rejected}" | sed "s/ ${commit_tag} //")" + err "Commit validation done by tag: ${commit_tag} ${newrev}" continue fi - for obj in $objects; do + for obj in ${objects}; do - if git verify-commit "$obj" >/dev/null 2>&1; then - true "Commit validation succeeded commit: $obj" + if git verify-commit "${obj}" >/dev/null 2>&1; then + true "Commit validation succeeded commit: ${obj}" continue else - err "No valid signature in commit: $obj" - obj_rejected="${obj_rejected-} $obj " + err "No valid signature in commit: ${obj}" + obj_rejected="${obj_rejected-} ${obj} " fi done done -test -n "$obj_rejected" || exit 0 +test -n "${obj_rejected}" || exit 0 -obj_rejected="$(echo "$obj_rejected" | tr -s " " | +obj_rejected="$(echo "${obj_rejected}" | tr -s " " | sed -e "s/^ //" -e "s/ $//")" -err "Couldn't verify objects: $obj_rejected" +err "Couldn't verify objects: ${obj_rejected}" exit 1 ## Force signed pushes if receive.certNonceSeed is set. @@ -168,42 +173,42 @@ if git config --get receive.certNonceSeed >/dev/null 2>&1; then fi while read -r oldrev newrev ref; do - true "$oldrev $newrev $ref" - test "$newrev" = "$zero" && continue + true "${oldrev} ${newrev} ${ref}" + test "${newrev}" = "${zero}" && continue - if test "$oldrev" = "$zero"; then - objects="$(git rev-list "$newrev")" + if test "${oldrev}" = "${zero}"; then + objects="$(git rev-list "${newrev}")" else - objects="$(git rev-list "$oldrev..$newrev")" + objects="$(git rev-list "${oldrev}..${newrev}")" fi - obj_type="$(git cat-file -t "$newrev")" - if test "$obj_type" = "tag"; then - if git verify-tag "$newrev" >/dev/null 2>&1; then - true "Tag validation succeeded for tag: $newrev" + obj_type="$(git cat-file -t "${newrev}")" + if test "${obj_type}" = "tag"; then + if git verify-tag "${newrev}" >/dev/null 2>&1; then + true "Tag validation succeeded for tag: ${newrev}" else - obj_rejected="${obj_rejected-} $newrev " + obj_rejected="${obj_rejected-} ${newrev} " continue fi - commit_tag="$(git rev-list -n1 "$newrev")" - obj_rejected="$(echo "$obj_rejected" | sed "s/ $commit_tag //")" - err "Commit validation done by tag: $commit_tag $newrev" + commit_tag="$(git rev-list -n1 "${newrev}")" + obj_rejected="$(echo "${obj_rejected}" | sed "s/ ${commit_tag} //")" + err "Commit validation done by tag: ${commit_tag} ${newrev}" continue fi - for obj in $objects; do - if git verify-commit "$obj" >/dev/null 2>&1; then - true "Commit validation succeeded for commit: $obj" + for obj in ${objects}; do + if git verify-commit "${obj}" >/dev/null 2>&1; then + true "Commit validation succeeded for commit: ${obj}" continue else - err "No valid signature in commit: $obj" - obj_rejected="${obj_rejected-} $obj " + err "No valid signature in commit: ${obj}" + obj_rejected="${obj_rejected-} ${obj} " fi done done -test -n "$obj_rejected" || exit 0 +test -n "${obj_rejected}" || exit 0 -obj_rejected="$(echo "$obj_rejected" | tr -s " " | sed -e "s/^ //;s/ $//")" -err "Couldn't verify objects: $obj_rejected" +obj_rejected="$(echo "${obj_rejected}" | tr -s " " | sed -e "s/^ //;s/ $//")" +err "Couldn't verify objects: ${obj_rejected}" exit 1 diff --git a/files/git/.config/git/template/hooks/prepare-commit-msg b/files/git/.config/git/template/hooks/prepare-commit-msg index f639e57..67e603c 100755 --- a/files/git/.config/git/template/hooks/prepare-commit-msg +++ b/files/git/.config/git/template/hooks/prepare-commit-msg @@ -15,12 +15,12 @@ file="$1" #sha1="$3" char="$(git config --get core.commentChar || echo "#")" -template="$(git config --get commit.template | sed "s|^~/|$HOME/|")" +template="$(git config --get commit.template | sed "s|^~/|${HOME}/|")" -if test "$char" = "auto"; then +if test "${char}" = "auto"; then ## Try to skip the init.template comment char by getting the last match, as ## the template will be placed at the beginning of the file. - char="$(grep -E "^(#|;|@|!|$|%|^|&|\\||:) " "$file" | cut -c 1 | tail -n 1)" + char="$(grep -E "^(#|;|@|!|$|%|^|&|\\||:) " "${file}" | cut -c1 | tail -n1)" fi ## Remove the default instructional message and its following empty line. @@ -28,12 +28,12 @@ sed -i'' \ -e "/^. Please enter the commit message .*. Lines starting$/d" \ -e "/^. with '.' will be ignored, .* aborts the commit.$/ { N; d; }" \ - "$file" + "${file}" ## Replace init.template comment char to the core.commentChar line per line. -if test -f "$template"; then +if test -f "${template}"; then while read -r line; do - mod_line="$(echo "$line" | sed "s/^. /${char} /")" - sed -i'' "s/^${line}$/${mod_line}/" "$file" - done < "$template" + mod_line="$(echo "${line}" | sed "s/^. /${char} /")" + sed -i'' "s/^${line}$/${mod_line}/" "${file}" + done < "${template}" fi diff --git a/files/git/.local/bin/git-client-setup b/files/git/.local/bin/git-client-setup index ddcceba..64ad7be 100755 --- a/files/git/.local/bin/git-client-setup +++ b/files/git/.local/bin/git-client-setup @@ -7,8 +7,8 @@ ## Setup git client on new machine on a local/separate git configuration. set -eu -gitconfig_file="$HOME/.gitconfig.local" -signature_file="$HOME/.signature" +gitconfig_file="${HOME}/.gitconfig.local" +signature_file="${HOME}/.signature" vim_modeline="vim: ft=gitconfig" usage(){ @@ -30,20 +30,20 @@ email="$2" signingkey="$3" set_git_config(){ - git config --file "$gitconfig_file" "$1" "$2" + git config --file "${gitconfig_file}" "$1" "$2" } -set_git_config user.name "$user" -set_git_config user.email "$email" -set_git_config user.signingKey "$signingkey" +set_git_config user.name "${user}" +set_git_config user.email "${email}" +set_git_config user.signingKey "${signingkey}" -if test -s "$signature_file"; then - set_git_config format.signatureFile "$signature_file" +if test -s "${signature_file}"; then + set_git_config format.signatureFile "${signature_file}" else - set_git_config format.signature "$user" + set_git_config format.signature "${user}" fi grep \ -E "^;*\s+(vim:.*(\s+|:)|vim:(\s*))(ft|filetype)=gitconfig((\s+|:).*|$)" \ - -q "$gitconfig_file" || - sed -i'' "1i; $vim_modeline" "$gitconfig_file" + -q "${gitconfig_file}" || + sed -i'' "1i; ${vim_modeline}" "${gitconfig_file}" diff --git a/files/git/.local/bin/git-pager b/files/git/.local/bin/git-pager index 5e1a23b..a7aa261 100755 --- a/files/git/.local/bin/git-pager +++ b/files/git/.local/bin/git-pager @@ -7,7 +7,7 @@ set -eu if command -v delta >/dev/null; then - exec delta "$@" + exec delta "${@}" else : "${DIFF_HIGHLIGHT_SOURCE:=/usr/share/doc/git/contrib/diff-highlight}" : "${DIFF_HIGHLIGHT_EXEC:=/usr/share/git-core/contrib/diff-highlight}" @@ -26,5 +26,5 @@ else exec "${DIFF_HIGHLIGHT_EXEC}" | less -RS fi - exec less -RS "$@" + exec less -RS "${@}" fi diff --git a/files/git/.local/bin/git-server-setup b/files/git/.local/bin/git-server-setup index f8d1e73..ffb6c5a 100755 --- a/files/git/.local/bin/git-server-setup +++ b/files/git/.local/bin/git-server-setup @@ -7,7 +7,8 @@ ## Setup git server. set -eu -if ! test "$(id -u)" = "0"; then +uid="$(id -u)" +if ! test "${uid}" = "0"; then echo "This program requires root." >&2 exit 1 fi @@ -25,23 +26,23 @@ git_user="git" git_home="/var/git" git_shell="$(command -v git-shell)" -useradd -m "$git_user" -d "$git_home" -s "$git_shell" -mkdir -p "$git_home/src" +useradd -m "${git_user}" -d "${git_home}" -s "${git_shell}" +mkdir -p "${git_home}/src" -mkdir -p "$git_home/.ssh" -chmod 0700 "$git_home/.ssh" -touch "$git_home/.ssh/authorized_keys" -chmod 0600 "$git_home/.ssh/authorized_keys" +mkdir -p "${git_home}/.ssh" +chmod 0700 "${git_home}/.ssh" +touch "${git_home}/.ssh/authorized_keys" +chmod 0600 "${git_home}/.ssh/authorized_keys" -mkdir -p "$git_home/git-shell-commands" -cp -r "$git_home/.config/git/shell"/* "$git_home/git-shell-commands" -chmod -R 0755 "$git_home/git-shell-commands" +mkdir -p "${git_home}/git-shell-commands" +cp -r "${git_home}/.config/git/shell"/* "${git_home}/git-shell-commands" +chmod -R 0755 "${git_home}/git-shell-commands" git config --system receive.updateServerInfo true git config --system receive.advertisePushOptions true nonce="$(head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | cut -c 1-256)" -git config --system receive.certNonceSeed "$nonce" +git config --system receive.certNonceSeed "${nonce}" -chown -R "$git_user":"$git_user" "$git_home" +chown -R "${git_user}":"${git_user}" "${git_home}" diff --git a/files/net/.config/sh/profile.d/net.sh b/files/net/.config/sh/profile.d/net.sh index 3bf4ae9..bf74543 100755 --- a/files/net/.config/sh/profile.d/net.sh +++ b/files/net/.config/sh/profile.d/net.sh @@ -4,8 +4,8 @@ ## ## SPDX-License-Identifier: AGPL-3.0-or-later -: "${XDG_CONFIG_HOME:=$HOME/.config}" +: "${XDG_CONFIG_HOME:=${HOME}/.config}" -CURL_HOME="$XDG_CONFIG_HOME/curl" -WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" +CURL_HOME="${XDG_CONFIG_HOME}/curl" +WGETRC="${XDG_CONFIG_HOME}/wget/wgetrc" export CURL_HOME WGETRC diff --git a/files/qvm-copy-dotfiles b/files/qvm-copy-dotfiles index 38ff6d7..ccbd441 100755 --- a/files/qvm-copy-dotfiles +++ b/files/qvm-copy-dotfiles @@ -1,6 +1,6 @@ #!/bin/sh ## -## SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +## SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. ## ## SPDX-License-Identifier: AGPL-3.0-or-later ## @@ -15,26 +15,30 @@ set -eu test -n "${1:-}" || { echo "usage: ${0##*/} QUBE"; exit 1; } -test "$(id -u)" = "0" || { echo "Program requires root."; exit 1; } +uid="$(id -u)" +test "${uid}" = "0" || { echo "Program requires root."; exit 1; } -vm="$1" -qvm-check "$vm" >/dev/null 2>&1 || { echo "VM doesn't exist: '$vm'"; exit 1; } +qube="${1-}" +if ! qvm-check -- "${qube}" >/dev/null 2>&1; then + echo "VM doesn't exist: '${qube}'" + exit 1 +fi test -f ./setup.sh || { echo "File doesn't exist: './setup.sh'"; exit 1; } -if test "$vm" = "dom0"; then +if test "${qube}" = "dom0"; then sh ./dotfiles/setup.sh user_name="$(getent group qubes | awk -F "[:,]" '{print $4}')" user_home="$(getent passwd "${user_name}" | awk -F ":" '{print $6}')" sudo -u "${user_name}" mkdir -pv "${user_home}/.cache" tmpdir="$(sudo -u "${user_name}" mktemp -d "${user_home}/.cache/XXXXXX")" - trap 'rm -rf -- "$tmpdir"' EXIT INT HUP QUIT ABRT - cp -r ./dotfiles "$tmpdir" - chown -R "${user_name}:${user_name}" "$tmpdir" - sudo -u "${user_name}" "$tmpdir/dotfiles/setup.sh" + trap 'rm -rf -- "${tmpdir}"' EXIT INT HUP QUIT ABRT + cp -r ./dotfiles "${tmpdir}" + chown -R "${user_name}:${user_name}" "${tmpdir}" + sudo -u "${user_name}" "${tmpdir}/dotfiles/setup.sh" exit fi -qvm-run -q "$vm" -- "rm -rf ~/QubesIncoming/dom0/files" -qvm-copy-to-vm "$vm" ../files -qvm-run -q "$vm" -- "sh ~/QubesIncoming/dom0/files/setup.sh" -qvm-run -q "$vm" -- "rm -rf ~/QubesIncoming/dom0/files" +qvm-run -q "${qube}" -- "rm -rf ~/QubesIncoming/dom0/files" +qvm-copy-to-vm "${qube}" ../files +qvm-run -q "${qube}" -- "sh ~/QubesIncoming/dom0/files/setup.sh" +qvm-run -q "${qube}" -- "rm -rf ~/QubesIncoming/dom0/files" diff --git a/files/setup.sh b/files/setup.sh index 3cd6c67..d1e9949 100755 --- a/files/setup.sh +++ b/files/setup.sh @@ -7,15 +7,15 @@ set -eu prg="$0" -if ! test -e "$prg"; then - case "$prg" in +if ! test -e "${prg}"; then + case "${prg}" in (*/*) exit 1;; - (*) prg=$(command -v -- "$prg") || exit;; + (*) prg=$(command -v -- "${prg}") || exit;; esac fi -dir="$(cd -P -- "$(dirname -- "$prg")" && pwd -P)" || exit 1 -prg="$dir/$(basename -- "$prg")" || exit 1 -cd -- "$dir" || exit 1 +dir="$(cd -P -- "$(dirname -- "${prg}")" && pwd -P)" || exit 1 +prg="${dir}/$(basename -- "${prg}")" || exit 1 +cd -- "${dir}" || exit 1 usage(){ printf '%s\n' "Usage: ${0##*/} [-h|--help] DIR [DIR2...]" @@ -29,17 +29,23 @@ case "${1-}" in *) args="${*}";; esac -for dir in $args; do - case "${dir##*/}" in "."|"..") continue;; esac +for dir in ${args}; do + case "${dir##*/}" in + "."|"..") continue;; + *) ;; + esac dir="${dir%*/}" - test -f "$dir" && continue - if ! test -d "$dir"; then - printf '%s\n' "Directory doesn't exist: '$dir'." >&2 + test -f "${dir}" && continue + if ! test -d "${dir}"; then + printf '%s\n' "Directory doesn't exist: '${dir}'." >&2 exit 1 fi - for file in "$dir"/.*; do - test -e "$file" || continue - case "${file##*/}" in "."|"..") continue;; esac - cp -rv "$file" "$HOME" + for file in "${dir}"/.*; do + test -e "${file}" || continue + case "${file##*/}" in + "."|"..") continue;; + *) ;; + esac + cp -rv "${file}" "${HOME}" done done diff --git a/files/sh/.config/bash/bash_env b/files/sh/.config/bash/bash_env index 467e3fb..520656a 100644 --- a/files/sh/.config/bash/bash_env +++ b/files/sh/.config/bash/bash_env @@ -7,9 +7,9 @@ # shellcheck disable=SC1090,SC1091 -if test -z "$ENV" && test -n "$PATH"; then +if test -z "${ENV}" && test -n "${PATH}"; then case $- in *l*) ;; - *) . "$HOME/.bash_profile" >/dev/null ;; + *) . "${HOME}/.bash_profile" >/dev/null ;; esac fi diff --git a/files/sh/.config/bash/bash_profile b/files/sh/.config/bash/bash_profile index cdd8f46..249e011 100644 --- a/files/sh/.config/bash/bash_profile +++ b/files/sh/.config/bash/bash_profile @@ -6,5 +6,8 @@ # shellcheck disable=SC1090,1091 -. "$HOME/.profile" -case $- in *i*) . "$HOME/.bashrc";; esac +. "${HOME}/.profile" +case $- in + *i*) . "${HOME}/.bashrc";; + *) ;; +esac diff --git a/files/sh/.config/bash/bashrc b/files/sh/.config/bash/bashrc index 90f33ff..f7977c1 100644 --- a/files/sh/.config/bash/bashrc +++ b/files/sh/.config/bash/bashrc @@ -13,9 +13,9 @@ esac ## Source default files. # shellcheck disable=SC1090,SC1091 -source "$HOME/.profile" +source "${HOME}/.profile" # shellcheck disable=SC1090 -source "$ENV" +source "${ENV}" ## }}} ## {{{ Options HISTCONTROL=ignoredups @@ -39,20 +39,27 @@ fi _reset_line() { case "${TERM-}" in ""|dumb|linux*|vt100*|vt220*) return;; + *) ;; esac ## Credit: Can't find the source, posted on StackExchange or alike. ## Does not work well on Bash 5.0 and older. - test "$(echo "${BASH_VERSION%.*}" | tr -d ".")" -lt 51 && return + bash_version_clean="$(echo "${BASH_VERSION%.*}" | tr -d ".")" + if test "${bash_version_clean}" -lt 51; then + unset bash_version_clean + return + fi + unset bash_version_clean - local termios cur_y ## Ask the terminal for any pending (line buffered) input. - termios=$(stty -g) && stty -icanon && stty "$termios" + termios="$(stty -g)" && stty -icanon && stty "${termios}" + unset termios ## On pending input, assume it's been echoed and we're not in first column. ## Otherwise ask the terminal for current column and read it from input. if read -t 0 || { - IFS='[;' read -s -r -d'R' -p$'\033[6n' _ _ cur_y && [[ $cur_y != 1 ]] + IFS='[;' read -s -r -d'R' -p$'\033[6n' _ _ cur_y && [[ ${cur_y} != 1 ]] } then + unset cur_y ## Print line ending char with reversed video and end with newline. if test "${color_prompt-}" = "yes"; then printf '%b' "\033[41m\033[0m\033[7m%\033[m\n\r" @@ -79,12 +86,13 @@ newline=$'\n' if test "${color_prompt:-}" = "yes"; then # shellcheck disable=SC2154 PS1="\$(_reset_line)\$(resize-terminal)\[\033[35m\][\[${reset_color}\]" - PS1="${PS1}${debian_chroot:+($debian_chroot)}\[${usercolor}\]\u@\h " + PS1="${PS1}${debian_chroot:+(${debian_chroot})}\[${usercolor}\]\u@\h " PS1="${PS1}\[${dircolor}\]\w\[${reset_color}\]\$(_git_prompt_info)" PS1="${PS1}\[\033[35m\]]\[${reset_color}\]${newline-}\$(_print_ec)" PS1="${PS1}${ps1_symbol} " else - PS1="\$(_reset_line)\$(resize-terminal)[${debian_chroot:+($debian_chroot)}" + PS1="\$(_reset_line)\$(resize-terminal)" + PS1="${PS1}[${debian_chroot:+(${debian_chroot})}" PS1="${PS1}\u@\h:\w\$(_git_prompt_info)]${newline-}\$(_print_ec)" PS1="${PS1}${ps1_symbol} " fi @@ -92,8 +100,9 @@ fi case "${TERM-}" in screen*|xterm*|rxvt*) ## Set window title - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + PS1="\[\e]0;${debian_chroot:+(${debian_chroot})}\u@\h: \w\a\]${PS1}" ;; + *) ;; esac case "${TERM-}" in @@ -113,13 +122,21 @@ fi unset newline ps1_symbol ## }}} ## {{{ Plugins -! has zoxide || eval "$(zoxide init bash)" -! has gitlint || eval "$(_GITLINT_COMPLETE=bash_source gitlint)" +if has zoxide; then + zoxide_bash_completion="$(zoxide init bash)" + eval "${zoxide_bash_completion}" + unset zoxide_bash_completion +fi +if has gitlint; then + gitlint_bash_completion="$(_GITLINT_COMPLETE=bash_source gitlint)" + eval "${gitlint_bash_completion}" + unset gitlint_bash_completion +fi source_readable /usr/share/doc/fzf/examples/key-bindings.bash source_readable /usr/share/doc/fzf/examples/completion.bash ## }}} ## {{{ End ## Source local bash configuration. -source_readable "$HOME/.bashrc.local" +source_readable "${HOME}/.bashrc.local" ## }}} diff --git a/files/sh/.config/less/lessfilter b/files/sh/.config/less/lessfilter index 839001c..8798fae 100755 --- a/files/sh/.config/less/lessfilter +++ b/files/sh/.config/less/lessfilter @@ -14,6 +14,7 @@ if test -d "$1"; then else case $1 in *.json) command -v jq >/dev/null && exec jq -C . "$1";; + *) ;; esac fi diff --git a/files/sh/.config/sh/profile b/files/sh/.config/sh/profile index f19d4d4..cbf18f3 100644 --- a/files/sh/.config/sh/profile +++ b/files/sh/.config/sh/profile @@ -5,56 +5,61 @@ ## SPDX-License-Identifier: AGPL-3.0-or-later ## Not so invasive because it only assigns a value if it is empty. +# shellcheck disable=SC2312 : "${HOME:=$(cd ~ && pwd)}" +# shellcheck disable=SC2312 : "${USER:=$(id -un || printf %s "${HOME##*/}")}" -: "${UID:=$(id -u || awk -F ":" -v user="$USER" '/^user:/{print $3}' \ +# shellcheck disable=SC2312 +: "${UID:=$(id -u || awk -F ":" -v user="${USER}" '/^user:/{print $3}' \ /etc/passwd)}" +# shellcheck disable=SC2312 : "${HOSTNAME:=$(hostname)}" export HOME USER UID HOSTNAME ## Set XDG_*_HOME variables. -XDG_CONFIG_HOME="$HOME/.config" -XDG_CACHE_HOME="$HOME/.cache" -XDG_DATA_HOME="$HOME/.local/share" -XDG_STATE_HOME="$HOME/.local/state" +XDG_CONFIG_HOME="${HOME}/.config" +XDG_CACHE_HOME="${HOME}/.cache" +XDG_DATA_HOME="${HOME}/.local/share" +XDG_STATE_HOME="${HOME}/.local/state" export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_STATE_HOME -mkdir -p \ - "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_DATA_HOME" "$XDG_STATE_HOME" +mkdir -p "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_DATA_HOME}" \ + "${XDG_STATE_HOME}" ## Set XDG_*_DIR variables. -eval "$(grep "^[ ]*XDG_[A-Z].*_DIR=" "$XDG_CONFIG_HOME/user-dirs.dirs" | - sed "s/^/export /")" +xdg_dirs="$(awk '/^[ ]*XDG_[A-Z]*_DIR=/{print "export " $1}' \ + "${XDG_CONFIG_HOME}/user-dirs.dirs")" +eval "${xdg_dirs}" ## Set directory to be used for coding. -CODEDIR="$HOME/src" +CODEDIR="${HOME}/src" export CODEDIR ## Set shell configuration directories. -SHDIR="$XDG_CONFIG_HOME/sh" -BASHDIR="$XDG_CONFIG_HOME/bash" -ZDOTDIR="$XDG_CONFIG_HOME/zsh" +SHDIR="${XDG_CONFIG_HOME}/sh" +BASHDIR="${XDG_CONFIG_HOME}/bash" +ZDOTDIR="${XDG_CONFIG_HOME}/zsh" export SHDIR BASHDIR ZDOTDIR ## Set general variables. -PATH="$HOME/bin:$HOME/.local/bin/$HOSTNAME:$HOME/.local/bin" -PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -PATH="$PATH:/usr/local/games:/usr/games" -INFOPATH="$HOME/.local/share/info:/usr/local/share/info:/usr/local/info" -INFOPATH="$INFOPATH:/usr/share/info:/usr/info" -MANPATH="$HOME/.local/share/man:/usr/local/man:/usr/local/share/man" -MANPATH="$MANPATH:/usr/X11R6/man:/opt/man:/snap/man:/usr/man:/usr/share/man" -ENV="$SHDIR/shrc" -BASH_ENV="$BASHDIR/bash_env" +PATH="${HOME}/bin:${HOME}/.local/bin/${HOSTNAME}:${HOME}/.local/bin" +PATH="${PATH}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +PATH="${PATH}:/usr/local/games:/usr/games" +INFOPATH="${HOME}/.local/share/info:/usr/local/share/info:/usr/local/info" +INFOPATH="${INFOPATH}:/usr/share/info:/usr/info" +MANPATH="${HOME}/.local/share/man:/usr/local/man:/usr/local/share/man" +MANPATH="${MANPATH}:/usr/X11R6/man:/opt/man:/snap/man:/usr/man:/usr/share/man" +ENV="${SHDIR}/shrc" +BASH_ENV="${BASHDIR}/bash_env" TMPDIR="/tmp" LANG="en_US.UTF-8" LANGUAGE="${LANG%.*}" -LC_ALL="$LANG" -GNUPGHOME="$HOME/.gnupg" +LC_ALL="${LANG}" +GNUPGHOME="${HOME}/.gnupg" export PATH INFOPATH MANPATH ENV TMPDIR LANG LANGUAGE LC_ALL GNUPGHOME ## Set interactive shell variables. HISTSIZE=10000 EDITOR="$(has -s vim vim.tiny vi)" -test -n "$EDITOR" && VISUAL="$EDITOR" +test -n "${EDITOR}" && VISUAL="${EDITOR}" TERMINAL="x-terminal-emulator" BROWSER="chromium" PAGER="less" @@ -82,18 +87,18 @@ export FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS FZF_TMUX ## 'vim.tiny' and 'vi' fails if VIMINIT is set to our vimrc. if has vim; then - if test -f "$XDG_CONFIG_HOME/vim/vimrc"; then + if test -f "${XDG_CONFIG_HOME}/vim/vimrc"; then # shellcheck disable=SC2016,SC2089 - VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | so $MYVIMRC' + VIMINIT='let $MYVIMRC="${XDG_CONFIG_HOME}/vim/vimrc" | so $MYVIMRC' # shellcheck disable=SC2090 export VIMINIT fi fi ## XDG_CONFIG_HOME: user-specific configuration files -GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" -KDEHOME="$XDG_CONFIG_HOME/kde" -INPUTRC="$BASHDIR/inputrc" +GTK2_RC_FILES="${XDG_CONFIG_HOME}/gtk-2.0/gtkrc-2.0" +KDEHOME="${XDG_CONFIG_HOME}/kde" +INPUTRC="${BASHDIR}/inputrc" if has less; then lesskey_src=0 less_version="$(less -V | awk -F '[ .]' 'NR==1 {print $2}')" @@ -102,54 +107,56 @@ if has less; then *) if test "${less_version}" -ge 582; then lesskey_src=1; fi;; esac if test "${lesskey_src}" = "1"; then - LESSKEY="$XDG_CONFIG_HOME/less/lesskey" + LESSKEY="${XDG_CONFIG_HOME}/less/lesskey" elif has lesskey; then - LESSKEY="$XDG_CONFIG_HOME/less/lesskey-old" - lesskey -o "$LESSKEY" "$XDG_CONFIG_HOME/less/lesskey" + LESSKEY="${XDG_CONFIG_HOME}/less/lesskey-old" + lesskey -o "${LESSKEY}" "${XDG_CONFIG_HOME}/less/lesskey" fi unset lesskey_src less_version fi export GTK2_RC_FILES KDEHOME INPUTRC LESSKEY ## XDG_DATA_HOME: user-specific data files -RUSTUP_HOME="$XDG_DATA_HOME/rustup" -CARGO_HOME="$XDG_DATA_HOME/cargo" -GOPATH="$XDG_DATA_HOME/go" -WORKON_HOME="$XDG_DATA_HOME/virtualenvs" -ELECTRUMDIR="$XDG_DATA_HOME/electrum" -TERMINFO="$XDG_DATA_HOME/terminfo" +RUSTUP_HOME="${XDG_DATA_HOME}/rustup" +CARGO_HOME="${XDG_DATA_HOME}/cargo" +GOPATH="${XDG_DATA_HOME}/go" +WORKON_HOME="${XDG_DATA_HOME}/virtualenvs" +ELECTRUMDIR="${XDG_DATA_HOME}/electrum" +TERMINFO="${XDG_DATA_HOME}/terminfo" export RUSTUP_HOME CARGO_HOME GOPATH WORKON_HOME ELECTRUMDIR TERMINFO ## XDG_STATE_HOME: user-specific state files, persists application restarts -LESSHISTFILE="$XDG_STATE_HOME/history-less" -HISTFILE="$XDG_STATE_HOME/history-shell" +LESSHISTFILE="${XDG_STATE_HOME}/history-less" +HISTFILE="${XDG_STATE_HOME}/history-shell" export LESSHISTFILE HISTFILE ## XDG_CACHE_HOME: user-specific non-essential data files -GOCACHE="$XDG_CACHE_HOME/go-build" -GOMODCACHE="$XDG_CACHE_HOME/go/mod" +GOCACHE="${XDG_CACHE_HOME}/go-build" +GOMODCACHE="${XDG_CACHE_HOME}/go/mod" export GOCACHE GOMODCACHE ## Start agents -ssh_agent_dir="$TMPDIR/ssh-agent-$USER" -ssh_agent_sock="$ssh_agent_dir/agent.sock" -ssh_agent_pid="$ssh_agent_dir/agent.pid" +ssh_agent_dir="${TMPDIR}/ssh-agent-${USER}" +ssh_agent_sock="${ssh_agent_dir}/agent.sock" +ssh_agent_pid="${ssh_agent_dir}/agent.pid" if test -z "${SSH_AUTH_SOCK-}" && has ssh-agent; then - test -d "$ssh_agent_dir" || mkdir -p "$ssh_agent_dir" - if test -S "$ssh_agent_sock" && - test -r "$ssh_agent_sock" && - test -w "$ssh_agent_sock" && - test -f "$ssh_agent_pid" && - test -r "$ssh_agent_pid" && - test -s "$ssh_agent_pid" + test -d "${ssh_agent_dir}" || mkdir -p "${ssh_agent_dir}" + if test -S "${ssh_agent_sock}" && + test -r "${ssh_agent_sock}" && + test -w "${ssh_agent_sock}" && + test -f "${ssh_agent_pid}" && + test -r "${ssh_agent_pid}" && + test -s "${ssh_agent_pid}" then - SSH_AUTH_SOCK="$ssh_agent_sock" - read -r SSH_AGENT_PID < "$ssh_agent_pid" + SSH_AUTH_SOCK="${ssh_agent_sock}" + read -r SSH_AGENT_PID < "${ssh_agent_pid}" export SSH_AUTH_SOCK SSH_AGENT_PID else - rm -f "$ssh_agent_sock" "$ssh_agent_pid" - eval "$(ssh-agent -s -a "$ssh_agent_sock")" >/dev/null - echo "$SSH_AGENT_PID" | tee "$ssh_agent_pid" >/dev/null + rm -f "${ssh_agent_sock}" "${ssh_agent_pid}" + ssh_agent_env="$(ssh-agent -s -a "${ssh_agent_sock}")" + eval "${ssh_agent_env}" >/dev/null + unset ssh_agent_env + echo "${SSH_AGENT_PID}" | tee "${ssh_agent_pid}" >/dev/null fi fi unset ssh_agent_dir ssh_agent_sock ssh_agent_pid @@ -159,11 +166,11 @@ unset ssh_agent_dir ssh_agent_sock ssh_agent_pid if test -n "${ZSH_VERSION:-}"; then setopt no_nomatch fi -for f in "$XDG_CONFIG_HOME/sh/profile.d"/*.sh; do +for f in "${XDG_CONFIG_HOME}/sh/profile.d"/*.sh; do # shellcheck disable=SC1090,SC1091 - ! test -r "$f" || . "$f" + ! test -r "${f}" || . "${f}" done ## Source local profile. # shellcheck disable=SC1090,SC1091 -! test -r "$HOME/.profile.local" || . "$HOME/.profile.local" +! test -r "${HOME}/.profile.local" || . "${HOME}/.profile.local" diff --git a/files/sh/.config/sh/shrc b/files/sh/.config/sh/shrc index 5a753c1..96ca202 100644 --- a/files/sh/.config/sh/shrc +++ b/files/sh/.config/sh/shrc @@ -16,7 +16,7 @@ esac ## Source profile. # shellcheck disable=SC1091 -. "$HOME/.profile" +. "${HOME}/.profile" ## }}} ## {{{ Options stty -ixon @@ -27,7 +27,7 @@ stty werase undef ## }}} ## {{{ Alias ## Standard commands. -test -n "$VISUAL" && alias vi='$VISUAL' +test -n "${VISUAL-}" && alias vi='${VISUAL}' alias du="du -h" alias df="df -h" alias cp="cp -i" @@ -35,8 +35,8 @@ alias mv="mv -i" alias ls="ls -hF --group-directories-first --color=auto" if has lsblk; then _lsblk_options="NAME,FSTYPE,LABEL,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT" - alias lsblk='lsblk -o $_lsblk_options' - alias lsblku='lsblk -o $_lsblk_options,UUID,PARTUUID' + alias lsblk='lsblk -o ${_lsblk_options}' + alias lsblku='lsblk -o ${_lsblk_options},UUID,PARTUUID' fi if ! grep --color 2>&1 | grep -qE "(unrecognized|unknown) option" && ! grep --exclude 2>&1 | grep -qE "(unrecognized|unknown) option" @@ -53,23 +53,34 @@ has highlight && alias highlight="highlight --out-format=ansi" has pygmentize && alias pygmentize="pygmentize -f terminal" ## Helpers. -alias reload='. $ENV' r="reload" -alias reload-xprofile='. $XDG_CONFIG_HOME/x11/xprofile' rx="reload-xprofile" +alias reload='. ${ENV}' r="reload" +if test -f "${XDG_CONFIG_HOME:-${HOME}/.config}/x11/xprofile"; then + alias reload-xprofile='. ${XDG_CONFIG_HOME:-${HOME}/.config}/x11/xprofile' + alias rx="reload-xprofile" +fi cd_up(){ # SPDX-FileCopyrightText: 2014 Grigory K # SPDX-License-Identifier: CC-BY-SA-3.0 # Credits: https://stackoverflow.com/a/26134858 case "${1-}" in - [1-9]) cd "$(printf "%0.0s../" $(seq 1 "$1"))" || return;; - "") cd .. || return;; - *) cd "$(pwd | sed -r "s|(.*/$1[^/]*/).*|\1|")" || return + [1-9]) + has seq || return + # shellcheck disable=SC2312 + cd "$(printf "%0.0s../" $(seq 1 "${1}"))" || return + ;; + "") + cd .. || return;; + *) + # shellcheck disable=SC2312 + cd "$(pwd | sed -r "s|(.*/${1}[^/]*/).*|\1|")" || return + ;; esac } alias up="cd_up" ## POSIX cd does not allow '--' and other shells breaks when not using it. alias -- -="cd -" 2>/dev/null || true -test -n "$EDITOR" && alias e='$EDITOR' -test -n "$VISUAL" && alias v='$VISUAL' +test -n "${EDITOR-}" && alias e='${EDITOR}' +test -n "${VISUAL-}" && alias v='${VISUAL}' alias j="jobs" alias h="history" alias l="ls -CF" @@ -114,7 +125,7 @@ has tmux && { tcla(){ ## Clear all the panes of the current session. for _t_pane in $(tmux list-panes -s -F '#{pane_id}'); do - tmux clear-history -t "$_t_pane" + tmux clear-history -t "${_t_pane}" done } } @@ -136,7 +147,7 @@ then g_alias="$(git config --get-regexp 'alias.*' | sed 's/^alias\.//;s/ .*//')" for key in $(printf '%s\n' "${g_alias}"); do # shellcheck disable=SC2139,SC2140 - alias "g$key"="git $key" + alias "g${key}"="git ${key}" done unset g_alias fi @@ -164,16 +175,20 @@ esac if test "${color_prompt-}" = "yes"; then if has dircolors; then ## Use dircolors if available. - if test -r "$XDG_CONFIG_HOME/dircolors/dircolors"; then - eval "$(dircolors -b "$XDG_CONFIG_HOME/dircolors/dircolors")" + if test -r "${XDG_CONFIG_HOME}/dircolors/dircolors"; then + dircolors="$(dircolors -b "${XDG_CONFIG_HOME}/dircolors/dircolors")" + eval "${dircolors}" else - eval "$(dircolors -b)" + dircolors="$(dircolors -b)" + eval "${dircolors}" fi + unset dircolors ## Fix bold on some terminals. case "${TERM-}" in xterm*|screen*) - LS_COLORS="$(echo "$LS_COLORS" | sed -e 's/01;3/00;9/g')" + LS_COLORS="$(echo "${LS_COLORS}" | sed -e 's/01;3/00;9/g')" ;; + *) ;; esac export LS_COLORS else @@ -232,16 +247,16 @@ _git_prompt_info(){ esac if test -n "${ZSH_VERSION-}"; then # shellcheck disable=2016 - if test "$color_prompt" = "yes"; then - print -Pn '(%%{$branchcolor%%}%20>...>$ref%<<%%{\e[00m%%})' + if test "${color_prompt}" = "yes"; then + print -Pn '(%%{${branchcolor}%%}%20>...>${ref}%<<%%{\e[00m%%})' else - print -Pn '(%20>...>$ref%<<)' + print -Pn '(%20>...>${ref}%<<)' fi else - if test "$color_prompt" = "yes"; then - printf '%s' "($branchcolor$ref$reset_color)" + if test "${color_prompt}" = "yes"; then + printf '%s' "(${branchcolor}${ref}${reset_color})" else - printf '%s' "($ref)" + printf '%s' "(${ref})" fi fi unset ref @@ -273,17 +288,20 @@ case "${ZSH_VERSION-}" in esac # shellcheck disable=SC2034 -if test "$(id -u)" = "0"; then +uid="$(id -u)" +if test "${uid}" = "0"; then usercolor="$(printf '%b' "\e[00;97m")" ps1_symbol="#" fi +unset uid ## Do not colorize this prompt, Sh fails to count the correct number of ## characters on the prompt leading to problems. +user="$(id -un)" if test "${color_prompt-}" = "yes"; then - PS1="[${usercolor}$(id -un) $(hostname -s)${reset_color}]${ps1_symbol} " + PS1="[${usercolor}${user} $(hostname -s)${reset_color}]${ps1_symbol} " else - PS1="$(id -un)@$(hostname -s)${ps1_symbol} " + PS1="${user}@$(hostname -s)${ps1_symbol} " fi ## }}} ## {{{ External Functions @@ -291,7 +309,7 @@ fi ## Source file if it is readable. ## Usage: source_readable FILE source_readable(){ - for _file in "$@"; do + for _file in "${@}"; do # shellcheck disable=SC1090 ! test -r "${_file}" || . "${_file}" done @@ -301,23 +319,23 @@ _fzf_comprun() { _fzf_command="$1" shift - case "$_fzf_command" in + case "${_fzf_command}" in cd) if has tree; then - fzf --preview 'tree -C {} | head -200' "$@" + fzf --preview 'tree -C {} | head -200' "${@}" else - fzf "$@" + fzf "${@}" fi ;; export|unset) - fzf --preview "eval 'echo \$'{}" "$@" + fzf --preview "eval 'echo \$'{}" "${@}" ;; ssh) if has dig; then - fzf --preview 'dig {}' "$@" + fzf --preview 'dig {}' "${@}" fi ;; *) - fzf --preview 'test -d {} || cat {}' "$@" + fzf --preview 'test -d {} || cat {}' "${@}" ;; esac } @@ -325,5 +343,5 @@ _fzf_comprun() { ## }}} ## {{{ End ## Source local shell configuration file. -source_readable "$HOME/.shrc.local" +source_readable "${HOME}/.shrc.local" ## }}} diff --git a/files/sh/.local/bin/get-script-dir b/files/sh/.local/bin/get-script-dir index 2814ed5..c3bb93c 100755 --- a/files/sh/.local/bin/get-script-dir +++ b/files/sh/.local/bin/get-script-dir @@ -11,14 +11,14 @@ set -eu test -n "${1-}" || exit 1 prg="$1" -if ! test -e "$prg"; then - case "$prg" in +if ! test -e "${prg}"; then + case "${prg}" in (*/*) exit 1;; - (*) prg=$(command -v -- "$prg") || exit 1;; + (*) prg=$(command -v -- "${prg}") || exit 1;; esac fi -dir="$(cd -P -- "$(dirname -- "$prg")" && pwd -P)" || exit 1 -prg="$dir/$(basename -- "$prg")" || exit 1 -printf '%s\n' "$dir" +dir="$(cd -P -- "$(dirname -- "${prg}")" && pwd -P)" || exit 1 +prg="${dir}/$(basename -- "${prg}")" || exit 1 +printf '%s\n' "${dir}" exit 0 diff --git a/files/sh/.local/bin/gpg-sign-email b/files/sh/.local/bin/gpg-sign-email index e6ffa7d..58a003d 100755 --- a/files/sh/.local/bin/gpg-sign-email +++ b/files/sh/.local/bin/gpg-sign-email @@ -33,15 +33,15 @@ if test -z "${1-}"; then fi vi_cmd="$(has -s vim vi)" -if test -z "$vi_cmd"; then +if test -z "${vi_cmd}"; then printf '%s\n' "Please install 'vi(m)'." exit 1 fi for f in "${@}"; do - cp "$f" "$f.asc" - "$vi_cmd" -u NONE \ + cp "${f}" "${f}.asc" + "${vi_cmd}" -u NONE \ -c 'set nomodeline' -c 'norm gg}j' \ -c '.,$!gpg -a --clear-sign' \ - -c 'wq' -- "$f.asc" + -c 'wq' -- "${f}.asc" done diff --git a/files/sh/.local/bin/has b/files/sh/.local/bin/has index a6aa53d..990ab7d 100755 --- a/files/sh/.local/bin/has +++ b/files/sh/.local/bin/has @@ -20,6 +20,8 @@ action="" test -n "${1-}" || exit 1 case "$1" in -s) action=show; shift; test -n "${1-}" || exit 1;; + "") echo "Argument required" >&2; exit 1;; + *) ;; esac for prog in "${@}"; do diff --git a/files/sh/.local/bin/requires-root b/files/sh/.local/bin/requires-root index a995cbf..33456d0 100755 --- a/files/sh/.local/bin/requires-root +++ b/files/sh/.local/bin/requires-root @@ -1,12 +1,13 @@ #!/bin/sh -## SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +## SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. ## ## SPDX-License-Identifier: AGPL-3.0-or-later ## Check if we are root, fail otherwise. set -eu -test "$(id -u)" -eq 0 && exit 0 +uid="$(id -u)" +test "${uid}" -eq 0 && exit 0 printf '%s\n' "Permission denied, action requires privileges." exit 1 diff --git a/files/sh/.local/bin/resize-terminal b/files/sh/.local/bin/resize-terminal index ded470e..a428ce9 100755 --- a/files/sh/.local/bin/resize-terminal +++ b/files/sh/.local/bin/resize-terminal @@ -45,7 +45,8 @@ fi if ! echo R | read -r -t 1 -sd R 2>/dev/null; then ## Fast but depends on XTerm. if has resize; then - eval "$(resize)" >/dev/null + resize_cmd="$(resize)" + eval "${resize_cmd}" >/dev/null exit fi ## Slow due to heavy stty calls. @@ -53,7 +54,7 @@ if ! echo R | read -r -t 1 -sd R 2>/dev/null; then stty raw -echo min 0 time 1 printf '\0337\033[r\033[99999;99999H\033[6n\0338' >/dev/tty IFS='[;R' read -r _ rows cols _ /dev/null || exit 1 : "${TMUX:=}" -ta_session="${1:-}" +session="${1:-}" ## Attach to session if it exists or not and from inside tmux or not. ## If name is supplied and doesn't exist, create session with given name. @@ -16,120 +16,120 @@ ta_session="${1:-}" ## else ask for the user to choose the wanted session. ## usage: ta SESSION ARGS ## example: ta dotfiles -d -ta_new(){ +new(){ ## Session name was not specified. - ta_list="$(tmux list-sessions 2>/dev/null)" + list="$(tmux list-sessions 2>/dev/null)" printf "Choose session or create one by providing a new name:\n" - if test -n "$ta_list"; then - printf %s"\n${ta_list}\n" + if test -n "${list}"; then + printf %s"\n${list}\n" fi printf "\nEnter session name: " - read -r ta_name + read -r name - if test -z "$ta_name"; then + if test -z "${name}"; then printf "Name cannot be empty.\n" return 1 fi } main(){ - if test -n "$TMUX"; then + if test -n "${TMUX}"; then ## Inside tmux. - if test "$ta_session" && tmux has-session -t "$ta_session" >/dev/null 2>&1 + if test "${session}" && tmux has-session -t "${session}" >/dev/null 2>&1 then ## Session name was specified and it exists. - tmux switch-client -t "$ta_session" - tmux display-message "Switched to session $ta_session" + tmux switch-client -t "${session}" + tmux display-message "Switched to session ${session}" - elif test -n "$ta_session"; then + elif test -n "${session}"; then ## Session name was specified but it doesn't exist. - tmux new-session -d -s "$ta_session" - tmux switch-client -t "$ta_session" - tmux display-message "Created and switched to session $ta_session" + tmux new-session -d -s "${session}" + tmux switch-client -t "${session}" + tmux display-message "Created and switched to session ${session}" else ## Session name was not specified. - ta_last="$(tmux display-message -p "#{client_last_session}")" - if test -n "$ta_last" && tmux has-session -t "$ta_last"; then + last="$(tmux display-message -p "#{client_last_session}")" + if test -n "${last}" && tmux has-session -t "${last}"; then ## If tmux has a last session, use it. - tmux switch-client -t "$ta_last" - tmux display-message "Switched to session $ta_last" + tmux switch-client -t "${last}" + tmux display-message "Switched to session ${last}" else ## No last session, choose one or create one. printf "Last session not found.\n" - ta_new || return 1 + new - if tmux has-session -t "$ta_name" 2>/dev/null; then + if tmux has-session -t "${name}" 2>/dev/null; then ## Chosen session exists. - tmux switch-client -t "$ta_name" - tmux display-message "Switched to session $ta_name" + tmux switch-client -t "${name}" + tmux display-message "Switched to session ${name}" else ## Chosen session doesn't exist. - tmux new-session -d -s "$ta_name" - tmux switch-client -t "$ta_name" - tmux display-message "Created and switched to session $ta_name" + tmux new-session -d -s "${name}" + tmux switch-client -t "${name}" + tmux display-message "Created and switched to session ${name}" fi fi fi else ## Outside of tmux. - if test -n "$ta_session" && ! tmux list-sessions >/dev/null 2>&1; then + if test -n "${session}" && ! tmux list-sessions >/dev/null 2>&1; then ## Session name was specified but server is not running. - tmux new-session -s "$ta_session" - tmux display-message "Created session $ta_session" + tmux new-session -s "${session}" + tmux display-message "Created session ${session}" return 0 elif ! tmux list-sessions >/dev/null 2>&1; then ## Server is not running. - ta_new || return 1 - tmux new-session -s "$ta_name" - tmux display-message "Created session $ta_name" + new + tmux new-session -s "${name}" + tmux display-message "Created session ${name}" return 0 fi - if test "$ta_session" && tmux has-session -t "$ta_session" >/dev/null 2>&1 + if test "${session}" && tmux has-session -t "${session}" >/dev/null 2>&1 then ## Session name was specified and it exists. - tmux attach-session -t "$ta_session" - tmux display-message "Attached to session $ta_session" + tmux attach-session -t "${session}" + tmux display-message "Attached to session ${session}" - elif test -n "$ta_session"; then + elif test -n "${session}"; then ## Session name was specified but it doesn't exist. - tmux new-session -s "$ta_session" - tmux display-message "Created new session $ta_session" + tmux new-session -s "${session}" + tmux display-message "Created new session ${session}" else ## Session name was not specified. - ta_last="$(tmux display-message -p "#{session_name}")" + last="$(tmux display-message -p "#{session_name}")" - if test -n "$ta_last" && tmux has-session -t "$ta_last"; then + if test -n "${last}" && tmux has-session -t "${last}"; then ## If tmux has a session name, use it. - tmux attach-session -t "$ta_last" - tmux display-message "Attached to session $ta_last" + tmux attach-session -t "${last}" + tmux display-message "Attached to session ${last}" else - ta_new || return 1 + new - if tmux has-session -t "$ta_name" 2>/dev/null; then + if tmux has-session -t "${name}" 2>/dev/null; then ## Chosen session exists. - tmux attach-session -t "$ta_name" - tmux display-message "Attached to session $ta_name" + tmux attach-session -t "${name}" + tmux display-message "Attached to session ${name}" else ## Chosen session doesn't exist. - tmux new-session -s "$ta_name" - tmux display-message "Created session $ta_name" + tmux new-session -s "${name}" + tmux display-message "Created session ${name}" fi fi fi fi } -main "$@" +main "${@}" diff --git a/files/tmux/.local/bin/tmux-sorcerer b/files/tmux/.local/bin/tmux-sorcerer index 2214a3a..0979056 100755 --- a/files/tmux/.local/bin/tmux-sorcerer +++ b/files/tmux/.local/bin/tmux-sorcerer @@ -11,8 +11,8 @@ ## In the absence of an argument, the script will try to find a 'plugin' ## directory at the defaults Tmux configuration directory in the following ## order (stops at first match): -## - ${XDG_CONFIG_HOME-$HOME/.config}/tmux/plugins -## - $HOME/.tmux/plugins +## - ${XDG_CONFIG_HOME-${HOME}/.config}/tmux/plugins +## - ${HOME}/.tmux/plugins ## ## Note '@plugin' definition is only useful for TPM, this script will source ## all plugins that are found. If you want to deactivate a plugin, move the @@ -29,12 +29,12 @@ set -eu get_plugin_path(){ - xdg_file="${XDG_CONFIG_HOME-$HOME/.config}/tmux/tmux.conf" - home_subdir_file="$HOME/.tmux/tmux.conf" - if test -f "$xdg_file"; then + xdg_file="${XDG_CONFIG_HOME-${HOME}/.config}/tmux/tmux.conf" + home_subdir_file="${HOME}/.tmux/tmux.conf" + if test -f "${xdg_file}"; then plugin_base="${xdg_file%/tmux.conf}/plugins" return 0 - elif test -f "$home_subdir_file"; then + elif test -f "${home_subdir_file}"; then plugin_base="${home_subdir_file%/tmux.conf}/plugins" return 0 fi @@ -45,16 +45,16 @@ set_plugin_path(){ while true; do test -n "${1-}" || break cur_arg="$1"; shift - case "$cur_arg" in + case "${cur_arg}" in "") break ;; *) - test -d "$cur_arg" || continue + test -d "${cur_arg}" || continue if test -n "${plugin_base-}"; then - plugin_base="${plugin_base-} $cur_arg"; continue + plugin_base="${plugin_base-} ${cur_arg}"; continue else - plugin_base="$cur_arg"; continue + plugin_base="${cur_arg}"; continue fi ;; esac @@ -64,32 +64,32 @@ set_plugin_path(){ source_plugins(){ directory="$1" ## See shellcheck SC2044 to understand why loops over find are fragile. - find "$directory" -maxdepth 1 -type d -not -name "$(printf "*\n*")" | \ + find "${directory}" -maxdepth 1 -type d -not -name "$(printf "*\n*")" | \ while read -r plugin do plugin_name="${plugin##*/}" plugin_name="${plugin_name##tmux-}" plugin_name="$(echo "${plugin_name}" | tr "-" "_")" - plugin_script="$plugin/$plugin_name.tmux" - test -r "$plugin_script" || continue - "$plugin_script" >/dev/null 2>&1 + plugin_script="${plugin}/${plugin_name}.tmux" + test -r "${plugin_script}" || continue + "${plugin_script}" >/dev/null 2>&1 done } plugin_base="" command -v tmux >/dev/null || exit 1 if test -n "${1-}"; then - set_plugin_path "$@" + set_plugin_path "${@}" else - get_plugin_path || exit 1 + get_plugin_path fi ## Don't fail if not directory was found test -n "${plugin_base-}" || exit 0 for p in ${plugin_base}; do - test -d "$p" || continue - source_plugins "$p" + test -d "${p}" || continue + source_plugins "${p}" done exit diff --git a/files/x11/.config/sh/profile.d/x11.sh b/files/x11/.config/sh/profile.d/x11.sh index a179538..69eb9a1 100755 --- a/files/x11/.config/sh/profile.d/x11.sh +++ b/files/x11/.config/sh/profile.d/x11.sh @@ -4,7 +4,7 @@ ## ## SPDX-License-Identifier: AGPL-3.0-or-later -: "${XDG_CONFIG_HOME:=$HOME/.config}" +: "${XDG_CONFIG_HOME:=${HOME}/.config}" -XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" +XINITRC="${XDG_CONFIG_HOME}/x11/xinitrc" export XINITRC diff --git a/files/x11/.config/x11/xinitrc b/files/x11/.config/x11/xinitrc index 1f0ea7d..3a718dc 100755 --- a/files/x11/.config/x11/xinitrc +++ b/files/x11/.config/x11/xinitrc @@ -5,5 +5,5 @@ ## SPDX-License-Identifier: AGPL-3.0-or-later # shellcheck disable=SC1090,SC1091 -test -r "$HOME/.profile" && . "$HOME/.profile" -. "${XDG_CONFIG_HOME:=$HOME/.config}/x11/xprofile" +test -r "${HOME}/.profile" && . "${HOME}/.profile" +. "${XDG_CONFIG_HOME:=${HOME}/.config}/x11/xprofile" diff --git a/files/x11/.config/x11/xprofile b/files/x11/.config/x11/xprofile index 2e7ae14..6123b88 100755 --- a/files/x11/.config/x11/xprofile +++ b/files/x11/.config/x11/xprofile @@ -17,7 +17,9 @@ if command -v xrdb >/dev/null; then fi ## If running normal OS or Qubes: Dom0, apply settings. -if ! command -v qubesdb-read >/dev/null || test "$(hostname)" = "dom0"; then +# shellcheck disable=3028 +hostname="${HOSTNAME:-$(hostname)}" +if ! command -v qubesdb-read >/dev/null || test "${hostname}" = "dom0"; then ## Decrease key repeat delay to X ms. ## Increase key repeat rate to Y per second. xset r rate 275 60 @@ -65,13 +67,14 @@ for wm in ${wm_list}; do if test "${wm}" = "dwm" && command -v xsetroot >/dev/null; then desktop_autostart while true; do - xsetroot -name "$(display-statusbar)" + xroot_name="$(display-statusbar)" + xsetroot -name "${xroot_name}" sleep 60 done & fi # shellcheck disable=SC2093 ${wm} & - wm_pid="$!" + wm_pid="${!}" done test -z "${wm_pid:-}" || wait "${wm_pid}" diff --git a/files/x11/.config/x11/xsession b/files/x11/.config/x11/xsession index 1f0ea7d..3a718dc 100755 --- a/files/x11/.config/x11/xsession +++ b/files/x11/.config/x11/xsession @@ -5,5 +5,5 @@ ## SPDX-License-Identifier: AGPL-3.0-or-later # shellcheck disable=SC1090,SC1091 -test -r "$HOME/.profile" && . "$HOME/.profile" -. "${XDG_CONFIG_HOME:=$HOME/.config}/x11/xprofile" +test -r "${HOME}/.profile" && . "${HOME}/.profile" +. "${XDG_CONFIG_HOME:=${HOME}/.config}/x11/xprofile" diff --git a/files/x11/.config/x11/xsessionrc b/files/x11/.config/x11/xsessionrc index eab6560..cf3f858 100755 --- a/files/x11/.config/x11/xsessionrc +++ b/files/x11/.config/x11/xsessionrc @@ -5,5 +5,5 @@ ## SPDX-License-Identifier: AGPL-3.0-or-later # shellcheck disable=SC1090,SC1091 -test -r "$HOME/.profile" && . "$HOME/.profile" -. "${XDG_CONFIG_HOME:=$HOME/.config}/x11/xsession" +test -r "${HOME}/.profile" && . "${HOME}/.profile" +. "${XDG_CONFIG_HOME:=${HOME}/.config}/x11/xsession"