mirror of
https://gitea.blesmrt.net/mikaela/shell-things.git
synced 2024-11-10 02:29:22 +01:00
profile.d/50-xdg-screenshots.sh: simplify logic and don't run as root
This commit is contained in:
parent
2d26f20efd
commit
8ce36b9c9e
@ -1,26 +1,27 @@
|
|||||||
# This script currently sets just the xdg screenshots directory, while I am
|
# OK, so this could be a lot more pretty, but it works for ensuring users have
|
||||||
# unsure of whether anything else than grimshot utilizes it.
|
# a screenshot directory (even if I still don't know does anything else than
|
||||||
|
# grimshot care about that).
|
||||||
|
|
||||||
# WARNING: my train of thought got disturbed writing this and I lost the red
|
# root is neither taking screenshots nor using gui
|
||||||
# thread of what the fluff was I doing again.
|
if [[ "$(id -u)" != "0" ]]; then
|
||||||
|
# if the configuration file exists, that is good enough indication for me
|
||||||
if [ $(hash xdg-user-dir 2> /dev/null) ] && [ $(hash xdg-user-dir-update 2> /dev/null) ]; then
|
# that the tools are supported.
|
||||||
echo "50-xdg-screenshots.sh ok" > /dev/null 2>&1
|
if [[ -f "$(xdg-user-dir)/.config/user-dirs.locale)" ]]; then
|
||||||
|
# If the output differs, the path is set and there is no need to
|
||||||
|
# continue.
|
||||||
|
if [[ $(xdg-user-dir SCREENSHOTS) != $(xdg-user-dir) ]]; then
|
||||||
|
# If we are continuing anyway, ensure existence of locale file and see if it's something I support.
|
||||||
|
touch "$(cat $(xdg-user-dir)/.config/user-dirs.locale)"
|
||||||
|
XDGLOCALE="$(cat $(xdg-user-dir)/.config/user-dirs.locale)"
|
||||||
|
if [[ "$XDGLOCALE" == "fi" || "$XDGLOCALE" == "fi_FI" ]]; then
|
||||||
|
# I would say Kuvankaappaukset, but for some reason KDE Plasma says Kuvakaappaukset, and I don't care enough.
|
||||||
|
xdg-user-dirs-update --set SCREENSHOTS $(xdg-user-dir PICTURES)/Kuvakaappaukset
|
||||||
|
else
|
||||||
|
# Generic English fallack, like I think upstream does.
|
||||||
|
xdg-user-dirs-update --set SCREENSHOTS $(xdg-user-dir PICTURES)/Screenshots
|
||||||
|
fi
|
||||||
|
# Ensure the directory exists.
|
||||||
|
mkdir -p "$(xdg-user-dir SCREENSHOTS)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(xdg-user-dir SCREENSHOTS) != $(xdg-user-dir) ]]; then
|
|
||||||
echo "50-xdg-screenshots.sh ok" > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the user has a locale preference
|
|
||||||
XDGLOCALE="$(cat $(xdg-user-dir)/.config/user-dirs.locale)"
|
|
||||||
|
|
||||||
# If the user wants Finnish, then let's respect that...
|
|
||||||
if [[ "$XDGLOCALE" == "fi" || "$XDGLOCALE" == "fi_FI" ]]; then
|
|
||||||
xdg-user-dirs-update --set SCREENSHOTS $(xdg-user-dir PICTURES)/Kuvakaappaukset
|
|
||||||
# ...otherwise English it is.
|
|
||||||
else
|
|
||||||
xdg-user-dirs-update --set SCREENSHOTS $(xdg-user-dir PICTURES)/Screenshots
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$(xdg-user-dir SCREENSHOTS)"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user