update envs for better XDG base directory support
This commit is contained in:
parent
f84a7005a5
commit
9f275c64c4
3 changed files with 72 additions and 2 deletions
|
@ -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/).
|
These dotfiles are managed by [chezmoi](https://www.chezmoi.io/).
|
||||||
|
|
||||||
> [!WARNING]
|
> [!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
|
# Quickstart
|
||||||
1. install chezmoi
|
1. install chezmoi
|
||||||
|
@ -47,4 +50,4 @@ chezmoi init https://codeberg.org/grassblock/hyprdots.git && chezmoi merge $FILE
|
||||||
- gradience nord (gtk4 & libadwaita)
|
- gradience nord (gtk4 & libadwaita)
|
||||||
- Utterly-Nord (qt)
|
- Utterly-Nord (qt)
|
||||||
- papirus-dark (icon)
|
- papirus-dark (icon)
|
||||||
- Nordzy-cursors (cursors)
|
- ~~Nordzy-cursors~~ Bibata-Modern-Ice (cursors)
|
||||||
|
|
30
home/private_dot_config/environment.d/xdg.conf
Normal file
30
home/private_dot_config/environment.d/xdg.conf
Normal file
|
@ -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
|
||||||
|
|
||||||
|
|
37
home/private_dot_config/python/pythonrc
Normal file
37
home/private_dot_config/python/pythonrc
Normal file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue