battery-warn | ||
check-system-update | ||
hotspot | ||
mount-nextcloud | ||
mount-nextcloud.desktop | ||
perform-system-update.patch | ||
README.md | ||
update-cargo-clif |
Some useful bash scripts
Here are some little bash scripts I coded along the way.
You can install all of them or just some individually. Be sure to check the script description in this README for additional instructions. (This could be critical. Please, read them.)
Generally, all of these scripts can be copied into your user's binary folder:
$ cp script_name ~/.local/bin/
$ chmod +x ~/.local/bin/script_name
You can check whether your shell looks for binaries in this path by running:
$ echo $PATH | grep ~/.local/bin
If there's text, you're good to go. If not, edit your shell's init file and add the following line:
export PATH=~/.local/bin:$PATH
Table of contents
- battery-warn
- hotspot
- update-cargo-clif
- mount-nextcloud
- check-system-update
battery-warn
Periodically query the battery level and play a sound if the level is low.
This script does not provide a help text!
I originally coded this because my display driver broke and I only had the console. Unfortunately the console doesn't come with any way to notify me when my battery is dying.
You can run battery-warn
in the background:
$ battery-warn &
It would be useful to add this line to your shell's init file if you need it regularly.
To check the battery level yourself run this:
$ battery-warn check
hotspot
Quickly start a wifi hotspot using NetworkManager.
This script does not provide a help text!
Starting/stopping the simple hotspot is as easy as:
$ hotspot
This will also show the SSID, password, and a QR-code.
In order to reduce power consumption it will also disable Wifi when disabling the hotspot. This behavior can be changed inside of the script (turn_off_wifi=0
). Or you can
only turn the hotspot off manually:
$ hotspot off
If you want to be sneaky, you can start a hidden hotspot with a different randomly generated password each time:
$ hotspot random
To show the SSID, password, and QR-code again without changing the hotspot:
$ hotspot show
update-cargo-clif
Download and install the latest build artifact for
rustc_codegen_cranelift
.
This script does not provide a help text!
This script also needs jq
to be installed.
Before using this script be sure to replace the $username
and $access_token
variables with your own GitHub username and an access
token with scope workflow
. (This will also enable the scope repo
.)
After the initial setup, run without arguments to download the latest GitHub Action build artifact for linux and install to /opt/cargo-clif:
$ update-cargo-clif
It will symlink the new cargo
command to /usr/local/bin/cargo-clif
(i.e. use with cargo-clif
when building your projects).
The script uses sudo
internally, so there is no need to run sudo update-cargo-clif
.
mount-nextcloud
Mount your Nextcloud account automatically using
gio
andpinentry
.
This script does not provide a help text!
Before using this script be sure to replace the $server
and $user
variables with your Nextcloud server and account.
If you are not using GNOME, replace pinentry-gnome3
with the correct pinentry
binary for your desktop environment.
You could run mount-nextcloud
manually (e.g. without a graphical UI in the console):
$ mount-nextcloud
But I recommend installing the autostart file. Assuming you are in the directory where you downloaded this repo:
$ cp mount-nextcloud.desktop ~/.config/autostart/
check-system-update
Update AUR and Flatpak packages directly and install Arch Linux packages from the repos at next boot.
This script does not provide a help text!
This script only works on distributions based on Arch Linux. You will also need to install systemd-system-update-pacman
from the AUR (e.g. with yay
):
$ yay -S systemd-system-update-pacman
Because the script downloads the packages into a special cache directory, you have to patch the updater script from that package. Assuming you are in the directory where you downloaded this repo:
$ sudo patch /usr/lib/systemd-system-update-pacman/perform-system-update{,.patch}
To check for any updates - be it from the AUR, Flatpak, or the repos - run:
$ check-system-update
This will update AUR packages and Flatpaks directly (i.e. now), and repo packages later at the next time you boot up you system, so you can go on with your work like nothing happened. If you have any critical system packages (e.g. drivers, kernels, etc.) installed from the AUR, installing them now could be a problem though. In order to check which packages come from non-repo sources, run:
$ pacman -Qm
The script uses sudo
internally, so there is no need to run sudo check-system-update
.
Contribution
Issues and Pull Requests are welcome. Please describe your problems or feature requests as detailed as possible.