From c597b01166c4ac4d042c2256826b69c6fb0bc405 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 23 Oct 2008 19:52:30 +0200 Subject: first init --- #upload-image.sh | 23 ++ 256colors2.pl | 64 +++ bashrun | 107 +++++ bashrun.sh | 1 + frag.pl | 35 ++ info.pl | 453 +++++++++++++++++++++ ipv6.sh | 49 +++ machine-update | 1108 +++++++++++++++++++++++++++++++++++++++++++++++++++ openbox_shutdown.sh | 13 + oss_mute.sh | 8 + pg_list_updater.sh | 18 + reformat_fstab.pl | 70 ++++ screen-locker.sh | 3 + screen.sh | 29 ++ set-background.sh | 41 ++ ssh-mount.sh | 17 + ssh-unmount.sh | 5 + unmount-ftp.sh | 7 + 18 files changed, 2051 insertions(+) create mode 100755 #upload-image.sh create mode 100644 256colors2.pl create mode 100755 bashrun create mode 120000 bashrun.sh create mode 100755 frag.pl create mode 100755 info.pl create mode 100755 ipv6.sh create mode 100755 machine-update create mode 100755 openbox_shutdown.sh create mode 100755 oss_mute.sh create mode 100755 pg_list_updater.sh create mode 100644 reformat_fstab.pl create mode 100755 screen-locker.sh create mode 100755 screen.sh create mode 100755 set-background.sh create mode 100755 ssh-mount.sh create mode 100755 ssh-unmount.sh create mode 100755 unmount-ftp.sh diff --git a/#upload-image.sh b/#upload-image.sh new file mode 100755 index 0000000..31447d5 --- /dev/null +++ b/#upload-image.sh @@ -0,0 +1,23 @@ +#/bin/dash +#----------------------------------------------------# +# File: upload-image.sh # +# Version: 0.1.0 # +# Date: 2008-10-6 # +# Author: Florian "Bluewind" Pritz # +# Upload image to imagebanana and output url # +#----------------------------------------------------# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +curl -F img="@$1" -F "send=Hochladen" -F 'resize=320x240' -H "Expect: " www.imagebanana.com -L | ack -o '(http.*?\/view\/.*?\..{3})' | tail -n 1 diff --git a/256colors2.pl b/256colors2.pl new file mode 100644 index 0000000..479ebb0 --- /dev/null +++ b/256colors2.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# Author: Todd Larason +# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $ + +# use the resources for colors 0-15 - usually more-or-less a +# reproduction of the standard ANSI colors, but possibly more +# pleasing shades + +# colors 16-231 are a 6x6x6 color cube +for ($red = 0; $red < 6; $red++) { + for ($green = 0; $green < 6; $green++) { + for ($blue = 0; $blue < 6; $blue++) { + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 36) + ($green * 6) + $blue, + int ($red * 42.5), + int ($green * 42.5), + int ($blue * 42.5)); + } + } +} + +# colors 232-255 are a grayscale ramp, intentionally leaving out +# black and white +for ($gray = 0; $gray < 24; $gray++) { + $level = ($gray * 10) + 8; + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 232 + $gray, $level, $level, $level); +} + + +# display the colors + +# first the system ones: +print "System colors:\n"; +for ($color = 0; $color < 8; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; +for ($color = 8; $color < 16; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n\n"; + +# now the color cube +print "Color cube, 6x6x6:\n"; +for ($green = 0; $green < 6; $green++) { + for ($red = 0; $red < 6; $red++) { + for ($blue = 0; $blue < 6; $blue++) { + $color = 16 + ($red * 36) + ($green * 6) + $blue; + print "\x1b[48;5;${color}m "; + } + print "\x1b[0m "; + } + print "\n"; +} + + +# now the grayscale ramp +print "Grayscale ramp:\n"; +for ($color = 232; $color < 256; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; + diff --git a/bashrun b/bashrun new file mode 100755 index 0000000..99e369c --- /dev/null +++ b/bashrun @@ -0,0 +1,107 @@ + +#!/bin/dash +# +# usage: bashrun [geometry] (default: 40x1) +# +# NOTE: commands entered will have an '&' appended before being run, +# so don't append it yourself, it will fail silently. +# +# rcfile: $HOME/.bashrunrc +# +# --------------------------------------------------------------------- + +GEOM=${1:-40x1} + +# create .bashrunrc unless present +BASHRUNRC=$HOME/.bashrunrc +if [ ! -f $BASHRUNRC ]; then +( +cat <<'EOF' +# which X terminal to use: +# (xterm|rxvt|urxvt|mrxvt|aterm|mlterm) +XTERM=urxvtc + +# history file and options: +HISTFILE=$HOME/.bashrun_history +HISTCONTROL=ignoredups:erasedups + +# bind to menu-complete. Makes cycle through completions on +# the current line instead of paging all possible completions +bind '"\t": menu-complete' + +# bind to send ^D +# ( is the default quit-chain-key in emacs, ratpoison, etc) +bind '"\C-g"':"\"\x04\"" + +# set a simple prompt +PS1=">" + +# ***DO NOT EDIT BEYOND THIS LINE*** +# +# bind ENTER to add ' &' to command +bind '"\x0d"':"\" &\n\"" +EOF +) > $BASHRUNRC +fi + +. $BASHRUNRC + +error() { + if [ `which zenity` ]; then + zenity --title bashrun --error --text "$@" + elif [ `which kdialog` ]; then + kdialog --title bashrun --error "$@" + elif [ `which xmessage` ]; then + xmessage "$@" + fi + echo -en "\007" + echo $@ +} + +# run bash terminal +if [ "$XTERM" = "xterm" ]; then + $XTERM -name 'bashrun' \ + -title 'bashrun' \ + -geometry $GEOM \ + -e "/bin/bash --rcfile $BASHRUNRC -i -t" + +elif [[ "$XTERM" = "aterm" || "$XTERM" = "mlterm" ]]; then + $XTERM -name 'bashrun' \ + -title 'bashrun' \ + -geometry $GEOM +sb \ + -e /bin/bash --rcfile $BASHRUNRC -i -t + +elif [[ "$XTERM" = "urxvt" || "$XTERM" = "rxvt" ]] || [ "$XTERM" = "urxvtc" ]; then + $XTERM -name 'bashrun' \ + -title 'bashrun' \ + -geometry $GEOM \ + -e sh -c "/bin/bash --rcfile $HOME/.bashrunrc -i -t" + + +elif [ "$XTERM" = "mrxvt" ]; then + $XTERM -name 'bashrun' \ + -title 'bashrun' \ + -geometry $GEOM +sb -ht \ + -e sh -c "/bin/bash --rcfile $BASHRUNRC -i -t" +else + error "$XTERM is not supported. Please check $BASHRUNRC" + exit 1 +fi + +# history cleanup... +# remove trailing whitespace and '&' from the last history line +tac $HISTFILE | sed "1s/\&//;s/ *$//" | tac > $HISTFILE + +# HISTCONTROL won't work on its own because bash applies the +# 'ignoredups' and 'erasedups' rules to 'command &'. + +# apply 'ignoredups' if set +if [[ "$HISTCONTROL" =~ "ignoredups" || "$HISTCONTROL" =~ "ignoreboth" ]]; then + uniq $HISTFILE $HISTFILE.tmp + mv $HISTFILE.tmp $HISTFILE +fi + +# apply 'erasedups' if set +if [[ "$HISTCONTROL" =~ "erasedups" ]]; then + tac $HISTFILE | gawk '!x[$0]++' - | tac > $HISTFILE +fi diff --git a/bashrun.sh b/bashrun.sh new file mode 120000 index 0000000..b37f7f0 --- /dev/null +++ b/bashrun.sh @@ -0,0 +1 @@ +bashrun \ No newline at end of file diff --git a/frag.pl b/frag.pl new file mode 100755 index 0000000..b8eb685 --- /dev/null +++ b/frag.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl -w + +#this script search for frag on a fs +use strict; + +#number of files +my $files = 0; +#number of fragment +my $fragments = 0; +#number of fragmented files +my $fragfiles = 0; + +#search fs for all file +open (FILES, "find " . $ARGV[0] . " -xdev -type f -print0 |"); + +$/ = "\0"; + +while (defined (my $file = )) { + open (FRAG, "-|", "filefrag", $file); + my $res = ; + if ($res =~ m/.*:\s+(\d+) extents? found/) { + my $fragment = $1; + $fragments += $fragment; + if ($fragment > 1) { + $fragfiles++; + } + $files++; + } else { + print ("$res : not understand for $file.\n"); + } + close (FRAG); +} +close (FILES); + +print ( $fragfiles / $files * 100 . "% non contiguous files, " . $fragments / $files . " average fragments.\n"); \ No newline at end of file diff --git a/info.pl b/info.pl new file mode 100755 index 0000000..0eb1bb1 --- /dev/null +++ b/info.pl @@ -0,0 +1,453 @@ +#!/usr/bin/perl +# http://bbs.archlinux.org/viewtopic.php?pid=395002 +use Switch; +use strict; +use File::Basename; + +#################### +## Config options ## +#################### + +## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ## +my $distro = "Archlinux"; +my $myArchVersion = "ArchLinux (Core Dump)"; + +## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ## +my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background"; + +## Takes a screen shot if set to 0 ## +my $shot = 0; +## Command to run to take screen shot ## +my $command = "scrot -d 10"; + +## What colors to use for the variables. ## +my $textcolor = "\e[0m"; + +## Prints little debugging messages if set to 0 ## +my $quite = 1; + + + +######################## +## Script starts here ## +######################## +## Define some thing to work with strict ## +my @line = (); +my $found = 0; +my $DE = "NONE"; +my $WM = "Beryl"; + +## Hash of WMs and the process they run ## +my %WMlist = ("Beryl", "beryl", + "Fluxbox", "fluxbox", + "Openbox", "openbox", + "Blackbox", "blackbox", + "Xfwm4", "xfwm4", + "Metacity", "metacity", + "Kwin", "kwin", + "FVWM", "fvwm", + "Enlightenment", "enlightenment", + "IceWM", "icewm", + "Window Maker", "wmaker", + "PekWM","pekwm" ); + +## Hash of DEs and the process they run ## +my %DElist = ("Gnome", "gnome-session", + "Xfce4", "xfce-mcs-manage", + "KDE", "ksmserver"); + +## Get Kernel version ## +if ( $display =~ "Kernel"){ + print "\::$textcolor Finding Kernel version\n" unless $quite == 1; + my $kernel = `uname -r`; + $kernel =~ s/\s+/ /g; + $kernel = " Kernel:$textcolor $kernel"; + push(@line, "$kernel"); +} + +## Find running processes ## +print "\::$textcolor Getting processes \n" unless $quite == 1; +my $processes = `ps -A | awk {'print \$4'}`; + +## Find DE ## +while( (my $DEname, my $DEprocess) = each(%DElist) ) { + print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1; + if ( $processes =~ m/$DEprocess/ ) { + $DE = $DEname; + print "\::$textcolor DE found as $DE\n" unless $quite == 1; + if( $display =~ m/DE/ ) { + push(@line, " DE:$textcolor $DE"); + } + last; + } +} + +## Find WM ## +while( (my $WMname, my $WMprocess) = each(%WMlist) ) { + print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1; + if ( $processes =~ m/$WMprocess/ ) { + $WM = $WMname; + print "\::$textcolor WM found as $WM\n" unless $quite == 1; + if( $display =~ m/WM/ ) { + push(@line, " WM:$textcolor $WM"); + } + last; + } +} + +## Find WM theme ## +if ( $display =~ m/Win_theme/ ){ + switch($WM) { + case "Openbox" { + print "\::$textcolor Finding $WM theme\n" unless $quite == 1; + open(FILE, "$ENV{HOME}/.config/openbox/rc.xml") + || die "\e[0;31m\n"; + while( ) { + if( /(.+)<\/name>/ ) { + while ( $found == 0 ) { + print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; + push(@line, " WM Theme:$textcolor $1"); + $found = 1; + } + } + } + close(FILE); + } + case "Metacity" { + print "\::$textcolor Finding $WM theme\n" unless $quite == 1; + my $gconf = `gconftool-2 -g /apps/metacity/general/theme`; + print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1; + chomp ($gconf); + push(@line, " WM Theme:$textcolor $gconf"); + } + case "Fluxbox" { + print "\::$textcolor Finding $WM theme\n" unless $quite == 1; + open(FILE, "$ENV{HOME}/.fluxbox/init") + || die "\e[0;31m\n"; + while( ) { + if( /session.styleFile:.*\/(.+)/ ) { + print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; + push(@line, " WM Theme:$textcolor $1"); + } + } + close(FILE); + } + case "Blackbox" { + print "\::$textcolor Finding $WM theme\n" unless $quite == 1; + open(FILE, "$ENV{HOME}/.blackboxrc") + || die "\e[0;31m\n"; + while( ) { + if( /session.styleFile:.*\/(.+)/ ) { + print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; + push(@line, " WM Theme:$textcolor $1"); + } + } + close(FILE); + } + case "Xfwm4" { + print "\::$textcolor Finding $WM theme\n" unless $quite == 1; + open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml") + || die "\e[0;31m\n"; + while( ) { + if( /