Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Gen2ly / memtop
Created August 2, 2012 23:39
Display the top application memory users
#!/bin/bash
# Display the top applications of memory usage
# http://www.cyberciti.biz/faq/linux-check-memory-usage/#comment-51021
while read command percent rss; do
if [[ "${command}" != "COMMAND" ]]; then
rss="$(bc <<< "scale=2;${rss}/1024")"
fi
printf " %-26s%-8s%s\n" "${command}" "${percent}" "${rss} MB" \
| sed 's/COMMAND/PROGRAM/' | sed 's/RSS MB/#MEM/'
@Gen2ly
Gen2ly / bckfile
Created December 24, 2013 21:31
Backup files with sequential numbering and optional tag
#!/bin/sh
# Backup files with sequential numbering and optional tag
# Display usage if given the incorrect number of parameters
if [ $# -ne 2 -a $# -ne 3 ]; then
echo "${0##*/} [file] [dir] [*tag]- Backup files with sequential numbering, opt. tag"
exit 1; fi
# Test if first and second parameters are a file and a directory
if [ ! -e "$1" ]; then
@Gen2ly
Gen2ly / gt
Created August 26, 2013 17:20
#!/bin/bash
# Create temporary file(s) and open in gedit
# Program required: gedit test
hash gedit 2>&- || { echo " Program required \"gedit\" not installed"; exit 1; }
# Display usage
if [[ $1 == -h ]]; then
echo "gt [name*] [name*]... - create temporary file(s) and open in gedit"
exit 1; fi
@Gen2ly
Gen2ly / lnk
Created July 5, 2013 14:15
Link shortcut
#!/bin/bash
# Link shortcut
# Display usage if incorrect number of parameters given
if [ $# != 2 ]; then
echo " ${0##*/} <source> <link> - ln shortcut"
exit 1; fi
# Source absolute path
if [ ! -e "$1" ]; then
@Gen2ly
Gen2ly / gpuswitch
Created September 12, 2012 12:22
Switch between AMD's integrated video card and discrete video card
#!/bin/bash
# Switch between AMD's integrated video card and discrete video card
# Active GPU
gpu_active=$(aticonfig --px-list | cut -d " " -f 2)
# Restart X.org server
xorg_restart () {
gnome-session-quit --logout # GNOME, will still prompt if unsaved
# --no-prompt causing problems
@Gen2ly
Gen2ly / bcksysc
Created August 31, 2012 20:15
Backup system configurations
#!/bin/bash
# Backup system configurations
# Source Directory (should be root (/) as include and exclude files use full paths)
src_dir="/"
# Destination Parent Directory
dsp_dir="/mnt/Backup"
dsp_dir="/run/media/todd/Backup/rsync"
@Gen2ly
Gen2ly / screencast
Created August 23, 2012 20:38
Create screencasts of area, full-screen, or window
#!/bin/bash
# Create screencasts of area, full-screen, or window
# Required program(s)
req_progs=(ffcast ffmpeg)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@Gen2ly
Gen2ly / cvlc.desktop
Created August 20, 2012 00:29
Type=Application
[Desktop Entry]
Type=Application
Name=cVLC
GenericName=Media Player
GenericName[ca]=Reproductor multimèdia
GenericName[de]=Medienwiedergabe
GenericName[fr]=Lecteur multimédia
GenericName[it]=Lettore multimediale
GenericName[ja]=メディアプレーヤー
X-GNOME-FullName=Command Line VLC
@Gen2ly
Gen2ly / devtop
Created August 2, 2012 23:36
Print disk usage
#!/bin/bash
# Print disk usage
# Key word exclusions (seperated by space)
exclude=(sandfox)
df -h | grep -e '^Filesystem' -e '^/dev' | \
grep -vf <(printf "%s\n" "${exclude[@]}") | \
sed 's/^/ /g'
@Gen2ly
Gen2ly / 90_externalmonitor
Created July 7, 2012 12:09
Enable external monitor if connected and disable laptop monitor, else v.v.
#!/bin/sh
# Enable external monitor if connected and disable laptop monitor, else v.v.
case "$1" in
resume | thaw )
export DISPLAY=:0
su -c - todd /home/todd/.scripts/bugfixes/externalmonitor
;;
esac