What's the most useful scipt you've written?

I just got into the whole scripting business and it's so flipping fun!
Yeasterday I made a script that automates disabling of .services that i dont need running. Figure it'd be useful after a fresh install, unless the up-and-comming future manjaro installer is super modular.
Now i just want new ideas to try out! Inspiration!

So. What's the most useful, super cool, or abundantly lazy script you ever wrote?

palemoon-sync, copies browser profile of Pale Moon to RAM, syncs it back to disc, should be run at start, at shutdown and maybe every hour or so. Useful for non-systemd systems where profile-sync-daemon doesn't work. It is instpired by https://wiki.archlinux.org/index.php/Firefox_on_RAM#The_script



set -efu

cd ~/.moonchild\ productions/pale\ moon

if [ ! -r $volatile ]; then
mkdir -m0700 $volatile

if [ "$(readlink $link)" != "$volatile" ]; then
mv $link $static
ln -s $volatile $link

if [ -e $link/.unpacked ]; then
rsync -av --delete --exclude .unpacked ./$link/ ./$static/
rsync -av ./$static/ ./$link/
touch $link/.unpacked

allservers which I run everyday that I'm at home (most days).

& mhwd-kern which I only need to run when I want to change the kernels that I run one way or another.

1 Like

now we have the Programming category
where is the code ? bsor

for inspiration you can read this topic archlinux forum

1 Like

The one I wrote is an archival script for my client. The script runs in *IX box and archives the oldest files provided the count of files is given as input. The server displays the timestamp of the file as Aug 30, 2016 if the file is created in the past six months and if it older than six months, the time stamp will be like 08/30/2015. The script heavily uses the awk command to achieve certain functionality, but that's complicated one.


pacli with a lot of help from pekman (he started it), Chrysostomus, and papajoker.
the development of pacli has stopped a while ago, though.

since then, i concentrated on pacli-simple (papajoker has continued to contribute valuable tips there). i am using pacli-simple almost every day and sometimes i have ideas for improvements.

in pacli-simple, i am especially proud of the "fix pacman errors" function, which fixes all regularly emerging pacman problems i have read about in this (and the old) forum. recently, i have added automatic removal of old log files to the "clean system" function. i have also added a brand new "configure system" function, which lets you edit about 30 important config files (because i could never remember their paths when i needed to edit them).

while these are almost full-blown CLI package managers, they are technically still bash scripts.


Not manjaro, but I wrote a script in Python to automate gui interactions with some software at work.

Rotating Backup.

well phonelist script always been useful to me :wink:

well its a basic script to add name,phone number, cell number, address and other stuff you wanna add
normally we i use it in the office for sudden costumer details.

you can find the script available in the web you can just modify it to your taste! :smiley:

1 Like

you can use functions,

clearService () {
    local name="$1"
    local service="$2"
    echo "i stop: ${name}"
    systemctl stop ${service}.service
    systemctl disable ${service}.service

prompt " ... " yesno
if [[ $yesno == "Y" || $yesno == "y" ]]; then # if or case: "Y/n/x(exit)"
    clearService "the Bluetooth" "bluetooth"
prompt " ... " yesno
if [[ $yesno =~ Y|y ]]; then
    clearService "the Wifi" "modemmanager"

one (dangerous) solution, use a Array :

services=($(systemctl list-units --state running -t service --no-pager --no-legend | awk '{print $1}'))
select choice in ${services[@]}; do 
    #echo "$choice"
    clearService "$choice"

# or for info, without SELECT
for i in ${!services[@]}; do
    echo "$i -> ${services[$i]}"
read ... choice
[[ -n "${services[$choice]}" ]] && ClearService "${services[$choice]}"

Edit: too dangerous or : remove some services in Array as dbus,tty,...

1 Like

The last script most useful i've written is to control fan speed of Nvidia card :expressionless:

#! /bin/bash
# nvidia-fanspeed
# `nvidia-fanspeed` check temperature and set fan speed value
# Requirements: nvidia-xconfig --cool-bits=4

# Custom configuration:
    "35 0"
    "40 20"
    "45 30"
    "50 40"
    "60 50"
    "65 60"
    "70 70"
    "75 80"
    "80 90"
    "100 100"

# Set fan control
nvidia-settings -a "GPUFanControlState=1" > /dev/null 2>&1

# Get temperature value
temp() {
    echo $1

# Get speed value
speed() {
    echo $2

# Get current Nvidia temperature
current_gpu_temp() {
    nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits

# Set target fan speed
set_fan_speed() {
    nvidia-settings -a "[fan:0]/GPUTargetFanSpeed=$1" > /dev/null 2>&1

while true; do
    for values in "${config[@]}"; do
        if [ $(current_gpu_temp) -lt $(temp $values) ]; then
    set_fan_speed $(speed $values)
    sleep 5
1 Like

you did not implemented a PI or PID regulator to regulate the temperature with a consign?:wink:

I have no idea about you say. Can you show me an example? :innocent:

if you want read something. it's more about regulation than bash scripting. :slight_smile:

1 Like

Mine is probably the script I made to automate manjaro-arm repo updates.

The script does the following:

  • Moves packages from build folder to merging folder.
  • Signs the packages in the merging folder.
  • Downloads Arch Linux ARM package repo (only updated packages) to Repo folder.
  • Removes packages from Repo folder, which are present in merging folder, with a list.
  • Copies packages and signatures from merging folder to Repo folder.
  • Symlinks "any" architecture packages into armv6h, armv7h and aarch64 folders in Repo folder.
  • Removes broken symlinks in Repo folder.
  • Run repo-add command on armv6h, armv7h and aarch64 folders in repo folder.
  • Rsync the entire Repo folder to my server, which host the Manjaro-ARM repository.

That script is now cronjob'd so it's done automaticly every day.

10 PRINT "Hello World!"
20 GOTO 10


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by