diff --git a/README.md b/README.md index 4c2528f..8f21648 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,10 @@ Best way to start off is install KDE first and make changes. These dotfiles are managed by [chezmoi](https://www.chezmoi.io/). > [!WARNING] -> since I'm starting to use kde plasma (again) so the updates to hyprland part would be slower, but other parts will be updated normally. +> Since I'm starting to use kde plasma (again) so the updates to hyprland part would be slower, but other parts will be updated normally. + +> [!WARNING] +> You may need to migrate existing configuration to `XDG` base folders, see [XDG Base Directory - ArchWiki](https://wiki.archlinux.org//title/XDG_Base_Directory) for details. To check whether to migrate, use [xdg-ninja](https://github.com/b3nj5m1n/xdg-ninja). # Quickstart 1. install chezmoi @@ -47,4 +50,4 @@ chezmoi init https://codeberg.org/grassblock/hyprdots.git && chezmoi merge $FILE - gradience nord (gtk4 & libadwaita) - Utterly-Nord (qt) - papirus-dark (icon) -- Nordzy-cursors (cursors) +- ~~Nordzy-cursors~~ Bibata-Modern-Ice (cursors) diff --git a/home/private_dot_config/environment.d/xdg.conf b/home/private_dot_config/environment.d/xdg.conf new file mode 100644 index 0000000..3e9d1fa --- /dev/null +++ b/home/private_dot_config/environment.d/xdg.conf @@ -0,0 +1,30 @@ +XDG_DATA_HOME=$HOME/.local/share +XDG_CONFIG_HOME=$HOME/.config +XDG_STATE_HOME=$HOME/.local/state +XDG_CACHE_HOME=$HOME/.cache + +# cleaning up home for applications +# adb +ANDROID_USER_HOME="$XDG_DATA_HOME"/android +# bash +HISTFILE="${XDG_STATE_HOME}"/bash/history +# cargo +CARGO_HOME="$XDG_DATA_HOME"/cargo +# novideo +CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv +# gradle +GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle +# java +_JAVA_OPTIONS="-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/java -Djavafx.cachedir=${XDG_CACHE_HOME}/openjfx" +# platformio +PLATFORMIO_CORE_DIR="$XDG_DATA_HOME"/platformio +# python (before v3.13.0,still beta) +PYTHONSTARTUP="$XDG_CONFIG_HOME"/python/pythonrc +# teamspeak +TS3_CONFIG_DIR=$XDG_CONFIG_HOME/ts3client +# wakatime +WAKATIME_HOME='$XDG_CONFIG_HOME/wakatime' +# wine +WINEPREFIX="$XDG_DATA_HOME"/wine + + diff --git a/home/private_dot_config/python/pythonrc b/home/private_dot_config/python/pythonrc new file mode 100644 index 0000000..afac62a --- /dev/null +++ b/home/private_dot_config/python/pythonrc @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# This entire thing is unnecessary post v3.13.0a3 +# https://github.com/python/cpython/issues/73965 + +def is_vanilla() -> bool: + """ :return: whether running "vanilla" Python """ + import sys + return not hasattr(__builtins__, '__IPYTHON__') and 'bpython' not in sys.argv[0] + + +def setup_history(): + """ read and write history from state file """ + import os + import atexit + import readline + from pathlib import Path + + # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables + if state_home := os.environ.get('XDG_STATE_HOME'): + state_home = Path(state_home) + else: + state_home = Path.home() / '.local' / 'state' + if not state_home.is_dir(): + print("Error: XDG_STATE_HOME does not exist at", state_home) + + history: Path = state_home / 'python_history' + + # https://github.com/python/cpython/issues/105694 + if not history.is_file(): + readline.write_history_file(str(history)) # breaks on macos + python3 without this. + + readline.read_history_file(history) + atexit.register(readline.write_history_file, history) + + +if is_vanilla(): + setup_history()