├── README.creole ├── buzz ├── CHANGES ├── TODO ├── buzz.sh ├── buzz.sh.1 └── buzz.sh.pod ├── cookieclean ├── CHANGES ├── TODO ├── cookieclean.ini ├── cookieclean.ok ├── cookieclean.sh ├── cookieclean.sh.1 └── cookieclean.sh.pod ├── duplicated ├── CHANGES ├── TODO ├── duplicated.sh ├── duplicated.sh.1 └── duplicated.sh.pod ├── killrenegade ├── CHANGES ├── TODO ├── killrenegade.ini ├── killrenegade.sh ├── killrenegade.sh.1 ├── killrenegade.sh.pod └── killstatistic.awk ├── lyndex ├── CHANGES ├── lyndex.ini └── lyndex.sh ├── minesweeper ├── CHANGES ├── TODO ├── minesweeper.sh ├── minesweeper.sh.6 └── minesweeper.sh.pod ├── mksfx ├── CHANGES ├── TODO ├── mksfx.sh ├── mksfx.sh.1 └── mksfx.sh.pod ├── mpc ├── CHANGES ├── TODO ├── mpc.sh ├── mpc.sh.1 └── mpc.sh.pod ├── onceaday ├── CHANGES ├── TODO ├── onceaday.ini ├── onceaday.sh ├── onceaday.sh.1 └── onceaday.sh.pod ├── pacman ├── CHANGES ├── TODO ├── pacman.sh ├── pacman.sh.1 └── pacman.sh.pod ├── psqall ├── CHANGES ├── TODO ├── psqall.ini ├── psqall.sh ├── psqall.sh.1 └── psqall.sh.pod ├── seq ├── CHANGES ├── TODO ├── seq.sh ├── seq.sh.1 └── seq.sh.pod ├── symlink_ntfs ├── CHANGES ├── symlink_ntfs.sh ├── symlink_ntfs.sh.1 └── symlink_ntfs.sh.pod ├── taborder ├── CHANGES ├── TODO ├── taborder.sh ├── taborder.sh.1 └── taborder.sh.pod └── termclock ├── CHANGES ├── TODO ├── termclock.sh ├── termclock.sh.1 └── termclock.sh.pod /README.creole: -------------------------------------------------------------------------------- 1 | = Bash Script 2 | 3 | The [[http://gnu.org/s/bash/|Bash]] shell used as default shell on GNU/Linux operating system is a versatile enhancement of the Bourne shell, suitable for use as 4 | interactive command processor and as script interpreter. 5 | 6 | This repository contains a collection of scripts, each directory contains one script and the related files. 7 | 8 | Here are some scripts I wrote. 9 | 10 | * **buzz.sh** - Schedules an at job to pop up a message using various commands. 11 | * **cookieclean.sh** - Cleans up the Mozilla cookie file removing unwanted items. 12 | * **duplicated.sh** - Create a list of all duplicated files based on comparing their checksums. 13 | * **killrenegade.sh** - Kill the processes with given name which use to much resources. 14 | * **lyndex.sh** - Create a word index from the Lynx traversal crawl files. 15 | * **minesweeper.sh** - The classic mine sweeper game in text mode. 16 | * **mksfx.sh** - Add a shell script header to a compressed file, to make it selfextractor. 17 | * **mpc.sh** - Just a rudimental frontend for the most basic music playing functionalities. 18 | * **onceaday.sh** - Run commands enumerated in a configuration file, conditionally, only once a day. 19 | * **pacman.sh** - Adds some frequently needed minor functionalities to pacman-g2. 20 | * **psqall.sh** - Runs the psql tool in a loop for more databases of the same server. 21 | * **seq.sh** - Use the seq command to replace numeric part of a string with numeric sequences and multiplying the string. 22 | * **onceaday.sh** - Run commands enumerated in a configuration file, conditionally, only once a day. 23 | * **psqall.sh** - Runs the psql tool in a loop for more databases of the same server. 24 | * **seq.sh** - Use the seq command to replace numeric part of a string with numeric sequences and multiplying the string. 25 | * **symlink_ntfs.sh** - Restores symlinks after copying them to NTFS and back. 26 | * **taborder.sh** - Reorders the controls in the XFM file based on the declarations in the Pas file. 27 | * **termclock.sh** - Analog clock displayed using only bash arithmetics and tput. 28 | 29 | These scripts were intentionally kept short. For details see the [[http://feherke.github.io/bash/|Bash section of my site]]. 30 | -------------------------------------------------------------------------------- /buzz/CHANGES: -------------------------------------------------------------------------------- 1 | 1.0 May 2004 2 | [+] Initial release. 3 | 4 | 1.1 September 2008 5 | [+] Alerts with the first tool found in a list of 10 notification tools : xmessage, Xdialog, kdialog, gdialog, zenity, xterm, eterm, aterm, terminal, konsole. 6 | 7 | 1.2 November 2010 8 | [+] Added 3 more notification tools : yad, vte, rxvt. 9 | 10 | 1.3 February 2013 11 | [+] Added 3 more notification tools : gxmessage, gtkdialog, gnome-terminal. 12 | [*] Added -title to the xterm notification. 13 | 14 | 15 | 16 | ( Legend : [+] added, [-] removed, [*] changed, [!] fixed ) 17 | -------------------------------------------------------------------------------- /buzz/TODO: -------------------------------------------------------------------------------- 1 | * Add more tools, for example gaffel. 2 | * Rewrite it all to make it configurable and modular. 3 | -------------------------------------------------------------------------------- /buzz/buzz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Buzz ! version 1.3 february 2013 written by Feherke 4 | # displays a predefined message at a given time 5 | 6 | 7 | # order of preferred commands 8 | commandlist=( gnome-terminal 'xmessage' 'Xdialog' 'kdialog' 'gdialog' 'zenity' 'yad' 'gxmessage' 'gtkdialog' 'xterm' 'eterm' 'aterm' 'terminal' 'konsole' 'vte' 'rxvt' ) 9 | 10 | # predefined message 11 | title='Buzz !' 12 | button='Yes, thank You' 13 | message=" Excuse me Sir, this is Your 14 | |~|_ _ _ ___ ___ |~| 15 | | / \ | || | |__ | |__ | | | 16 | | O ) | || | / / / / |_| 17 | |_\_/ \__/_| |___| |___| (_) 18 | 19 | * --=[ \$( date +%H:%M:%S ) ]=-- * 20 | 21 | ( Buzz was set at $( date +%H:%M:%S ). )" 22 | 23 | 24 | column=0 25 | line=1 26 | while read -r str; do 27 | (( line++ )) 28 | (( column=column>${#str}?column:${#str} )) 29 | done <<< "$( eval "echo \"$message\"" )" 30 | 31 | 32 | echo 'Buzz ! version 1.3 february 2013 written by Feherke' 33 | 34 | if [[ "$1" =~ ^-{1,2}(h(elp)?|\?)$ ]]; then 35 | echo \ 36 | 'displays a predefined message at a given time 37 | 38 | Syntax : 39 | buzz time 40 | 41 | Parameters : 42 | time - absolute or relative time, as required by at : 43 | H day-part 44 | HH:MM [month-name DD [YY[YY]]] 45 | HH:MM DD.MM.YY 46 | now + count time-unit 47 | ' 48 | exit 49 | fi 50 | 51 | time="$@" 52 | 53 | [[ "$time" ]] || { 54 | echo 'Error : required parameter missing' 55 | exit 56 | } 57 | 58 | 59 | for str in "${commandlist[@]}"; do 60 | type "$str" > /dev/null 2>&1 && { command="$str"; break; } 61 | done 62 | 63 | [[ "$command" ]] && { 64 | echo "The message will be displayed using $command" 65 | [[ "$DISPLAY" ]] && display="DISPLAY=$DISPLAY " || echo 'Warning : DISPLAY not set, the command may fail' 66 | } || echo 'The message will be sent to your local mailbox' 67 | 68 | case "$command" in 69 | 'xmessage') echo "$display xmessage -center -title '$title' -buttons '${button/,/\,}' -file - <<< \"$message\"" ;; 70 | 'Xdialog') echo "$display Xdialog --fixed-font --left --title '$title' --ok-label '$button' --no-cancel --textbox - 0 0 <<< \"$message\"" ;; 71 | 'kdialog') echo "$display kdialog --title '$title' --msgbox \"$message\" 2> /dev/null" ;; 72 | 'gdialog') echo "$display gdialog --title '$title' --msgbox \"$message\"" ;; 73 | 'zenity') echo "$display zenity --title='$title' --ok-label='$button' --info --text \"$message\"" ;; 74 | 'yad') echo "$display yad --title='$title' --button='$button' --text \"$message\"" ;; 75 | 'gxmessage') echo "$display gxmessage -fn fixed -bg gray -fg black -center -title '$title' -buttons '${button/,/\,}' \"$message\"" ;; 76 | 'gtkdialog') 77 | IFS='*' message=( $message ) 78 | message1="${message[1]}" 79 | message=( "${message[@]/#/}" ) 81 | message[1]="eval echo \"$message1\"" 82 | echo "$display dialog='${message[@]//\\/\`}' gtkdialog -c -p dialog" 83 | ;; 84 | 'xterm') echo "$display xterm -bg gray -fg black +sb -geometry '${column}x$line' -T '$title' -e \"echo '$message';read -p $'\e[42m $button \e[0m'\"" ;; 85 | 'eterm') echo "$display eterm -b gray -f black -P '' --no-cursor -s 0 --buttonbar 0 -g '${column}x$line' -T '$title' -e bash -c \"echo '$message';read -p $'\e[42m $button \e[0m'\"" ;; 86 | 'aterm') echo "$display aterm -bg gray -fg black -cr gray -sb -geometry '${column}x$line' -title '$title' -e bash -c \"echo '$message';read -p $'\e[42m $button \e[0m'\"" ;; 87 | 'terminal') echo "$display terminal --hide-toolbars --hide-menubar --geometry '${column}x$line' -T '$title' -x bash -c \"echo '$message';read -p $'\e[42m $button \e[0m'\"" ;; 88 | 'konsole') echo "$display konsole --vt_sz '${column}x$line' --noscrollbar --nomenubar --notoolbar --notabbar -T '$title !' -e bash -c \"echo '$message';read -p $'\e[42m $button \e[0m'\" 2> /dev/null" ;; 89 | 'rxvt') echo "$display rxvt -bg gray -fg black -cr gray -geometry '${column}x$line' -title '$title' -e bash -c \"echo '$message';read -p $'\e[42m $button \e[0m'\"" ;; 90 | 'gnome-terminal') echo "$display gnome-terminal --hide-menubar --geometry '${column}x$line' -t '$title' -e \"bash -c \\\"echo '$message';read -p $'\e[42m $button \e[0m'\\\"\"" ;; 91 | *) echo "echo \"$message\"" ;; 92 | esac | at $time 93 | -------------------------------------------------------------------------------- /buzz/buzz.sh.1: -------------------------------------------------------------------------------- 1 | .\" buzz.sh - displays a predefined message at a given time 2 | .TH buzz.sh 1 1.1 "September 2008" "Usefull Shell Script" 3 | .SH NAME 4 | \fBbuzz.sh\fP - displays a predefined message at a given time 5 | .SH SYNOPSIS 6 | \fBbuzz.sh\fP \fItime\fP 7 | .SH OPTIONS 8 | .TP 9 | \fItime\fP 10 | absolute or relative time, as required by at : 11 | .RS 12 | .PP 13 | H day-part 14 | .PP 15 | HH:MM [month-name DD [YY[YY]]] 16 | .PP 17 | HH:MM DD.MM.YY 18 | .PP 19 | now + count time-unit 20 | .RE 21 | .SH DESCRIPTION 22 | Schedules an \fBat\fP(1) job to pop up a message using various commands. 23 | .PP 24 | Currently the following commands are supported : 25 | \fBxmessage\fP(1), \fBXdialog\fP(1), \fBkdialog\fP(1), \fBgdialog\fP(1), \fBzenity\fP(1), \fBxterm\fP(1), \fBeterm\fP(1), \fBaterm\fP(1), \fBterminal\fP(1), \fBkonsole\fP(1). 26 | If none of the commands is found, the message be simply written to \fBstdout\fP, letting the daemon to deliver it to the local mailbox. 27 | .PP 28 | This script was optimized for simplicity, there is no explicit configuration. However the order of checking for the above commands and the predefined message can be 29 | easily modified in the script itself. 30 | .SH ENVIRONMENT 31 | .TP 32 | \fBDISPLAY\fP 33 | The value of the current \fBDISPLAY\fP is set for the job. If not set, displaying the message by the \fBatd\fP(8) will probably fail. 34 | .SH SEE ALSO 35 | \fBbash\fP(1), \fBat\fP(1); 36 | \fBxmessage\fP(1), \fBXdialog\fP(1), \fBkdialog\fP(1), \fBgdialog\fP(1), \fBzenity\fP(1), \fBxterm\fP(1), \fBeterm\fP(1), \fBaterm\fP(1), \fBterminal\fP(1), \fBkonsole\fP(1) 37 | .SH TO DO 38 | Add more commands to display the messages. 39 | Better configuration for the currently used commands. 40 | .SH BUGS 41 | No bugs until now. Found bugs can be reported to the author. 42 | .SH COPYRIGHT 43 | Use it healthy. 44 | .SH AUTHOR 45 | Feherke 46 | -------------------------------------------------------------------------------- /buzz/buzz.sh.pod: -------------------------------------------------------------------------------- 1 | --name=buzz.sh 2 | --release=1.3 3 | --date=February 2013 4 | --section=1 5 | --center=Useful Shell Script 6 | 7 | =head1 NAME 8 | 9 | B - displays a predefined message at a given time 10 | 11 | =head1 SYNOPSIS 12 | 13 | B I