From 60052659b98832c78c902e4f27ecee2663d8e913 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 6 May 2026 08:30:49 +0200 Subject: Added scripts --- scripts/old/brightness | 16 ++++++++ scripts/old/dmenu-filepicker-old | 31 +++++++++++++++ scripts/old/dunst-toggle | 14 +++++++ scripts/old/gfmt | 9 +++++ scripts/old/mail-checknow | 18 +++++++++ scripts/old/mblaze-extras | 61 +++++++++++++++++++++++++++++ scripts/old/notify-battery | 10 +++++ scripts/old/notify-status | 7 ++++ scripts/old/notify-time | 15 +++++++ scripts/old/sfeed-browser | 80 ++++++++++++++++++++++++++++++++++++++ scripts/old/theme | 23 +++++++++++ scripts/old/togglemute | 18 +++++++++ scripts/old/volume | 13 +++++++ scripts/old/xkboptions | 6 +++ scripts/old/xprop-active-window-id | 6 +++ 15 files changed, 327 insertions(+) create mode 100755 scripts/old/brightness create mode 100755 scripts/old/dmenu-filepicker-old create mode 100755 scripts/old/dunst-toggle create mode 100755 scripts/old/gfmt create mode 100755 scripts/old/mail-checknow create mode 100755 scripts/old/mblaze-extras create mode 100755 scripts/old/notify-battery create mode 100755 scripts/old/notify-status create mode 100755 scripts/old/notify-time create mode 100755 scripts/old/sfeed-browser create mode 100755 scripts/old/theme create mode 100755 scripts/old/togglemute create mode 100755 scripts/old/volume create mode 100755 scripts/old/xkboptions create mode 100755 scripts/old/xprop-active-window-id (limited to 'scripts/old') diff --git a/scripts/old/brightness b/scripts/old/brightness new file mode 100755 index 0000000..a7294fb --- /dev/null +++ b/scripts/old/brightness @@ -0,0 +1,16 @@ +#!/bin/sh + +# Increase / decrease brightness, and pops up a notification +# Requires: xbacklight, a notification program such as herbe or notify-send +# Usage: brightness {inc|dec} n + +# ksh completion +# set -A complete_brightness_1 inc dec +# set -A complete_brightness_2 5 + +#notify="notify-send" +notify="herbe" + +pkill herbe # comment this too if not using herbe + +xbacklight -$1 $2 && $notify "Brightness: $(xbacklight | sed 's/\..*$//')%" diff --git a/scripts/old/dmenu-filepicker-old b/scripts/old/dmenu-filepicker-old new file mode 100755 index 0000000..532fb82 --- /dev/null +++ b/scripts/old/dmenu-filepicker-old @@ -0,0 +1,31 @@ +#!/bin/sh + +# A dmenu-based file picker (prints selected file to stdout) +# Requires: dmenu (or similar) +# Usage: dmenu-filepicker [path] + +menu=${MENU:-dmenu} +menuopts="-i -l 15" + +basedir="$(pwd)" + +next="${@:-$(pwd)}" + +while true; do + if [ -z "$next" ]; then + break + elif [ "$next" = "." ]; then + pwd + break + elif [ -d "$next" ]; then + cd "$next" + next=$(ls -a | $menu $menuopts) + else + echo "$next" | while read line; do + echo "$(pwd)/$line" + done + break + fi +done + +cd "$basedir" diff --git a/scripts/old/dunst-toggle b/scripts/old/dunst-toggle new file mode 100755 index 0000000..2de2343 --- /dev/null +++ b/scripts/old/dunst-toggle @@ -0,0 +1,14 @@ +#!/bin/sh + +# Toggle "do not disturbe" mode with dunst +# Requires: dunst, notify-send + +if [ "$(dunstctl is-paused)" = "false" ]; then + notify-send -t 3000 "Notifications: OFF" "Notifications will be hidden" + sleep 3 + dunstctl set-paused true +else + dunstctl set-paused false + notify-send -t 3000 "Notifications: ON" "Notifications reactivated" +fi + diff --git a/scripts/old/gfmt b/scripts/old/gfmt new file mode 100755 index 0000000..d38351f --- /dev/null +++ b/scripts/old/gfmt @@ -0,0 +1,9 @@ +#!/bin/sh + +# Format text from gemtext format to short lines with double \n + +# TODO: remove double spacing from within ``` + +sed 's/ //' | \ +sed 'a\\' | \ +fold -sw 80 diff --git a/scripts/old/mail-checknow b/scripts/old/mail-checknow new file mode 100755 index 0000000..188042b --- /dev/null +++ b/scripts/old/mail-checknow @@ -0,0 +1,18 @@ +#!/bin/sh + +# Check for new email, save result to file. +# Requires: mpop, notify-send or similar + +file="$XDG_DATA_HOME/newmail" +#notify="notify-send" +notify=herbe + +l=$(cat "$file") +n=$(mpop -s | awk '/new*./{print $2}') + +if [ -n "$n" ]; then + echo "$n" > "$file" + if [ "$n" != "no" ] && [ "$l" != "$n" ]; then + $notify "New email ($n)" + fi +fi diff --git a/scripts/old/mblaze-extras b/scripts/old/mblaze-extras new file mode 100755 index 0000000..7a4fe8a --- /dev/null +++ b/scripts/old/mblaze-extras @@ -0,0 +1,61 @@ +#!/bin/sh + +# Useful extra commands for mblaze + +# Requires: mblaze, mpop + +# Usage: mblaze-extras command +# List of commands: +# get [filter] +# pick [field] +# save +# scan [folder] + +menu=${MENU:-dmenu} +mdir=$HOME/mail +mpopdir=$HOME/.config/mpop + +mbextra_scan() { + folder=${1:-inbox} + mlist -t $mdir/$folder | mthread | mseq -S + mscan +} + +mbextra_get() { + mpop --filter=$mpopdir/filter-$1.sh + minc -q $mdir/inbox + mbextra_scan inbox +} + +mbextra_pick() { + field=$1 + shift + mpick -t "$field =~~ \"$@\"" +} + +mbextra_save() { + dir=$2 + [ -z "$dir" ] && dir=$(dmenu-filepicker) + mkdir -p "$dir" + + if [ ! -d "$dir" ]; then + echo "No directory selected, skipping." + else + cd "$dir" + mshow -x $1 + fi +} + +if [ -z "$1" ]; then + echo "Usage: mblaze-extras COMMAND" +elif [ "$1" = "scan" ]; then + mbextra_scan $2 +elif [ "$1" = "get" ]; then + mbextra_get $2 +elif [ "$1" = "save" ]; then + shift + mbextra_save $@ +elif [ "$1" = "pick" ]; then + shift + mbextra_pick $@ +fi diff --git a/scripts/old/notify-battery b/scripts/old/notify-battery new file mode 100755 index 0000000..0294b70 --- /dev/null +++ b/scripts/old/notify-battery @@ -0,0 +1,10 @@ +#!/bin/sh + +# Popup battery notification, based on the script battery-status + +# Requires: notify-send or similar + +#notify=notify-send +notify=herbe + +$notify "Battery" "$(battery-status)" diff --git a/scripts/old/notify-status b/scripts/old/notify-status new file mode 100755 index 0000000..73a9435 --- /dev/null +++ b/scripts/old/notify-status @@ -0,0 +1,7 @@ +#!/bin/sh + +# Simple script to send a notification displaying the output of status + +# Requires: status, herbe (or similar, e.g. notify-send) + +herbe "$(status '\n\n')" diff --git a/scripts/old/notify-time b/scripts/old/notify-time new file mode 100755 index 0000000..4b77c74 --- /dev/null +++ b/scripts/old/notify-time @@ -0,0 +1,15 @@ +#!/bin/sh + +# Little notification to show time and date + +# Requires: notify-send or similar + +# TODO: check if it still works with notify-send + +#notify=notify-send +notify=herbe + +t=$(date +"%H:%M:%S") +d=$(date +"%d %B %Y, %A") + +$notify "$t" "$d" diff --git a/scripts/old/sfeed-browser b/scripts/old/sfeed-browser new file mode 100755 index 0000000..774c808 --- /dev/null +++ b/scripts/old/sfeed-browser @@ -0,0 +1,80 @@ +#!/bin/sh + +# This script is based on sfeed (https://codemadness.org/sfeed.html), but +# it allows you organize your feeds in directories and subdirectories. +# In your $sfd directory (see below) you should have two folders: +# urls: it can contain more subfolders and files. Each file should contain +# only one line with the url to the feed. The name of the file is the +# name of the feed (it can contains spaces and such). +# files: this one can be empty, it will be filled with the feed files +# An older version of this script also marked viewed items and removed +# them before displaying the choice of feeds. Contact me if you are interested +# in using it. + +# Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar) + +# Usage: sfeed-browser [-m menu] + +filepicker="dmenu-filepicker" # Try "nnn -p -" +menu="dmenu -l 35 -i" +urlopener=open-url +sfd="$HOME/box/sfeed" +showlast=10 + +usage() { + echo "sfeed-browser [-m MENU]" +} + +while getopts "m:" opt; do + case "$opt" in + m) + menu="$OPTARG" + ;; + *) + usage + exit 1 + ;; + esac +done + +# Might add more stuff later +fixurl() { + sed 's/old\.reddit\.com/reddit\.com/' +} + +dirtofeedpaths() { + while read -r line; do + find "$line" | while read -r fname; do + [ -f "$fname" ] && echo "$fname" + done + done +} + +pathstosfeedrc() { + printf 'sfeedpath="%s"\n\nfeeds() {\n' "$sfd/files" + while read -r line; do + feedname=$(echo "$line" | sed 's/.*\///') + read -r feedurl <"$line" + printf '\tfeed "%s" "%s"\n' "$feedname" "$feedurl" + done + printf "}\n" +} + +feedmenu() { + while read -r line; do + feedname=$(echo "$line" | sed 's/.*\///') + sfeed_plain "$sfd/files/$feedname" | head -$showlast + done | $menu +} + +openfeeds() { + while read -r line; do + url=$(echo "$line" | sed 's/.*[\t ]//' | fixurl) + [ -n "$url" ] && echo "$url" + done | xargs $urlopener +} + +$filepicker "$@" "$sfd/urls" | dirtofeedpaths > "$sfd/last" +pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" +sfeed_update "$sfd/sfeedrc" +feedmenu < "$sfd/last" | openfeeds diff --git a/scripts/old/theme b/scripts/old/theme new file mode 100755 index 0000000..7e0107a --- /dev/null +++ b/scripts/old/theme @@ -0,0 +1,23 @@ +#!/bin/sh + +# This script is a shortcut to change between a dark and a light theme +# for my terminal emulator (st). + +# Usage: theme (dark|light) + +src=$HOME/.local/src + +case "$@" in + dark) + cd $src/st-darkbg + ;; + light) + cd $src/st-lightbg + ;; + *) + echo "usage: theme (dark|light)" + exit 1 + ;; +esac + +make && sudo make install diff --git a/scripts/old/togglemute b/scripts/old/togglemute new file mode 100755 index 0000000..b799b02 --- /dev/null +++ b/scripts/old/togglemute @@ -0,0 +1,18 @@ +#!/bin/sh + +# Toggle mute state and notify +# Requires: pulsemixer, notify-send or similar + +#notify=notify-send +notify=herbe + +ismute=$(pulsemixer --toggle-mute --get-mute) + +if [ "$ismute" = "1" ]; then + m="muted" +else + m="unmuted" +fi + +pkill herbe # comment this line too if not using herbe +$notify "Audio $m" diff --git a/scripts/old/volume b/scripts/old/volume new file mode 100755 index 0000000..8dcd36a --- /dev/null +++ b/scripts/old/volume @@ -0,0 +1,13 @@ +#!/bin/sh + +# Change volume and notify +# Usage: volume {+n|-n} +# Requires: pulsemixer, notify-send or similar + +#notify=notify-send +notify=herbe + +newvol=$(pulsemixer --change-volume "$1" --get-volume | awk '{print $1}') + +pkill herbe # comment this line too if not using herbe +$notify "Volume" "$newvol%" diff --git a/scripts/old/xkboptions b/scripts/old/xkboptions new file mode 100755 index 0000000..e63456d --- /dev/null +++ b/scripts/old/xkboptions @@ -0,0 +1,6 @@ +#!/bin/sh + +# Loads my xkboptions + +setxkbmap -option compose:ralt +setxkbmap -option caps:swapescape diff --git a/scripts/old/xprop-active-window-id b/scripts/old/xprop-active-window-id new file mode 100755 index 0000000..97cf60f --- /dev/null +++ b/scripts/old/xprop-active-window-id @@ -0,0 +1,6 @@ +#!/bin/sh + +# Get the ID of the current active window (hexadecimal) +# Requires: xprop + +xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | sed 's/.* //' -- cgit v1.3