A small Bash command-line tool for checking and controlling common laptop services and hardware state on systemd-based Linux.
- Bash
- systemd tools (
systemctl,loginctl) - Common status utilities such as
awk,df,free,ps, anduptime - Optional:
nmcliandtailscalefor network and Tailscale details sudofor commands that change system state
The status commands read information from systemd, /proc, and /sys. Control commands use sudo to start or stop services, change the default boot target, set backlight power, or terminate a login session. Review the script before running it, especially before using commands that change state.
install -Dm755 laptopctl ~/.local/bin/laptopctlMake sure ~/.local/bin is on your PATH. Then run laptopctl --help.
The shell/ directory tracks the personal additions used on this laptop:
shell/path.shadds the installed local, Bun, OpenCode, and system administration directories toPATH, without adding duplicates. It also setsBUN_INSTALLwhen Bun is installed. Bash and POSIX shells can source it.shell/bashrc.bashloads that environment, defineslstat, and initializes zoxide when installed. It includes commented shortcuts for laptop controls and only runs in interactive Bash shells.
With this checkout at ~/laptopctl, add this at the end of ~/.bashrc:
if [ -r "$HOME/laptopctl/shell/bashrc.bash" ]; then
. "$HOME/laptopctl/shell/bashrc.bash"
fiAdd this at the end of ~/.profile so login shells also get the tool paths:
if [ -r "$HOME/laptopctl/shell/path.sh" ]; then
. "$HOME/laptopctl/shell/path.sh"
fiReplace the existing personal PATH, Bun, OpenCode, lstat, and zoxide additions with these hooks. Keep the rest of your shell configuration. Adjust both hook paths if you move the checkout. Edit the tracked files to change these settings, then open a new shell or run source ~/.bashrc.
The command in ~/.local/bin/laptopctl is an installed copy. Rerun the install command after editing the CLI.
laptopctl [status] [--all]
laptopctl gui {on|off|status}
laptopctl rdp {on|off|status}
laptopctl backlight {on|off|status}
laptopctl boot {gui|headless|status}
laptopctl sessions [-x|--exclude-xrdp]
laptopctl kill SESSION_ID
Short aliases are available for the command groups (g, r, bl, b, s, and k). Run laptopctl --help for examples and all options.
This tool targets Linux systems that use systemd. Battery, lid, thermal, and backlight details depend on the hardware and kernel interfaces exposed by the machine, so some fields may report unavailable.