This document provides context, patterns, and guidelines for AI coding assistants working in this repository.
This project contains useful scripts that automate some personal and general Linux tasks via Python and Bash/Shell.
- Languages: Python 3.x and POSIX shell / Bash
- Purpose: Collection of small utilities and automation scripts for Linux system tasks
- Python: 3.12+ with type hints
- BASH: POSIX shell / Bash scripts for automation tasks
- Linting: ruff (linter + formatter) for python files
- Type Checking: mypy
- Testing: pytest, bats
- Clone the repository:
git clone https://github.com/cyber-syntax/linux-system-utils.git - Install dependencies: Ensure Python 3.12+ is installed. Use
uvto start python scripts. - Deploy scripts: Run
./install.shto install scripts to XDG base directories (e.g.,~/.local/share/linux-system-utils). - Environment setup: No additional environment variables required beyond standard XDG paths.
- Edit scripts in the
src/directory. - For Python scripts: Use
uv runfor commands like linting, type checking, and testing. - For Bash scripts: Use
shellcheckfor linting andshfmtfor formatting. - No development server needed; scripts are standalone utilities.
- After changes, redeploy using
./install.sh --forceto update installed scripts.
- Python Testing: Test only complex scripts/modules that require extensive testing.
- Run specific test file:
uv run pytest tests/test_install.py - Run specific test function:
uv run pytest tests/test_install.py::test_install_success
- Run specific test file:
- Bash/Shell Testing:
- Check a single file:
shellcheck setup.sh - Check all shell scripts:
find . -name "*.sh" -type f -exec shellcheck {} \; - Check with specific severity:
shellcheck -S error setup.sh
- Check a single file:
- Function Size: Keep functions small and focused (<20 lines when possible)
- KISS: Keep it simple, stupid. Aim for simplicity and clarity. Avoid unnecessary abstractions or metaprogramming.
- DRY Approach:
- Reuse existing abstractions; don't duplicate
- Refactor safely when duplication is found
- Check existing protocols before creating new ones
- Type Annotations: Always use built-in generic types instead of
typingequivalents:- Use
list[str]notList[str](from typing) - Use
X | NonenotOptional[X](from typing) - Only import from
typingwhen absolutely necessary (e.g.,Any,Unionfor complex cases)
- Use
- PEP 8: Enforced by ruff
- Datetime: Use
astimezone()for local time conversions - Variable Names: Use descriptive, self-explanatory names
- Functions: Use functions over classes when state management is not needed
- Pure Functions: Prefer pure functions without side effects when possible
- Prefer plain bash constructs and avoid unnecessary complexity.
- Use built-in bash features where appropriate, but avoid overusing them.
- Build: No build process required; scripts are interpreted directly.
- Deployment: Use
./install.shto deploy to user directories. Options include--mainfor installing from main branch,--forceto overwrite,--binaryto install select scripts globally to~/.local/bin. - CI/CD: No automated pipelines defined; manual testing and deployment.
install.sh
containers/
docs/
src
├── audio # Audio-related scripts
│ ├── mediaplayer.py
│ ├── mediaplayer.sh
│ ├── sink-change.sh
│ └── volume-control.sh
├── automation # General automation scripts
│ ├── add-missing-i18n-variables.js
│ ├── add-xml-missing-variables.py
│ ├── copy-repos-to-vm.sh
├── backup # Backup-related scripts
│ ├── borg-backup
│ │ ├── home-borgbackup.sh
│ ├── rsync-desktop-to-laptop.sh
│ └── rsync-laptop-to-desktop.sh
├── containers # Container-related scripts and configurations
│ ├── autopenguinsetup_container
│ │ ├── Dockerfile.arch
│ │ ├── Dockerfile.fedora
│ │ ├── manage.sh
│ │ ├── podman-compose.yml
├── display # Display configuration scripts
│ ├── laptop-xrandr.sh
├── games # Game-related scripts
│ └── fs_mod_move.sh
├── general # General utility scripts
│ ├── remove-html-tag.py
│ ├── sha512_sum.sh
├── github # GitHub-related scripts and data
│ ├── changelog.sh
│ ├── data
│ │ ├── AGENTS_bash.md
│ │ ├── AGENTS_python.md
│ │ ├── pyproject.toml
├── hardware # Hardware-related scripts
│ ├── bluetooth-menu.sh
├── network # Network-related scripts
│ ├── network_test.sh
│ └── wakeonlan.wol
├── package-management # Package management scripts for various distros
│ ├── arch-package-manager.sh
│ ├── fedora-package-manager.sh
├── power # Power management and related scripts
│ ├── brightness-control.sh
│ ├── check_battery.sh
│ ├── idle.sh
│ ├── power-menu.sh
│ ├── swaylock.sh
│ └── swaylock_sleep.sh
├── system # System information and maintenance scripts
│ ├── info
│ │ ├── cpu_mem_info.sh
│ ├── maintenance
│ │ └── gc_cache.sh
│ └── setup-tty.sh
├── web-scrapping # Web scraping scripts
│ └── scrap.py
└── website # Personal website-related scripts and configurations
└── stow.sh
CRITICAL: Always run ruff on modified python files before committing.
# 1. Make your changes to files in src/
# 2. Run linting (auto-fix issues)
ruff check --fix path/to/file.py
ruff check --fix . # or all Python files
# 3. Run formatting
ruff format path/to/file.py
ruff format . # or all Python files
# 4. Run type checking
uv run mypy src/
# 5. Run fast tests
uv run pytest /path/to/file.py# Format a file (in-place)
shfmt -w setup.sh
# Format all shell scripts
find . -name "*.sh" -type f -exec shfmt -w {} \;
# Format options used in this project:
# -i 2 : indent with 2 spaces
# -ci : indent switch cases
# -bn : binary ops like && and | may start a line
shfmt -i 2 -ci -bn -w setup.sh- Ensure all linting, formatting, type checking, and tests pass before submitting.
- Required checks: Run
ruff check --fix,ruff format,uv run mypy src/,uv run pytest,shellcheck, andshfmton relevant files.