Skriptsammlung

Aus Geekbox Wiki
Wechseln zu: Navigation, Suche

i3lock mit blur

#!/bin/bash

# Dependencies: imagemagick, i3lock-color-git, scrot

IMAGE=$(mktemp).png
TEXT="Type password to unlock"

# get path where the script is located
# its used for the lock icon
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
 
# l10n support
case $LANG in
    fr_* ) TEXT="Entrez votre mot de passe" ;; # Français
    es_* ) TEXT="Ingrese su contraseña" ;; # Española
    pl_* ) TEXT="Podaj hasło" ;; # Polish
esac

VALUE="60" #brightness value to compare to
scrot $IMAGE
COLOR=`convert $IMAGE -colorspace hsb -resize 1x1 txt:- | sed -E '/.*$/ {
                             N
                             s/.*\n.*([0-9]{1,2}[^\.])\.[0-9]+%\)$/\1/
                             }'`;
# pixelate: -scale 10% -scale 1000%
if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text
    convert $IMAGE -level 0%,100%,0.6 \
        -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \
        -font Liberation-Sans -pointsize 26 -fill black -gravity center \
        -annotate +0+160 "$TEXT" \
        $SCRIPTPATH/lockdark.png -gravity center -composite $IMAGE
    PARAM='--textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e \
        --linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 \
        --insidevercolor=ffffff1c --ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c'
else #black
    convert $IMAGE -level 0%,100%,0.6 \
        -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \
        -font Liberation-Sans -pointsize 26 -fill white -gravity center \
        -annotate +0+160 "$TEXT" \
        $SCRIPTPATH/lock.png -gravity center -composite $IMAGE
    PARAM='--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e \
        --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 \
        --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c'
fi

# try to use a forked version of i3lock with prepared parameters
i3lock $PARAM -i $IMAGE > /dev/null 2>&1

if [ $? -ne 0 ]; then
    # We have failed, lets get back to stock one
    i3lock -i $IMAGE
fi

rm $IMAGE


lock.png

i3config x220

# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8

# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8

# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec i3-sensible-terminal

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
#bindsym $mod+d exec dmenu_run
bindsym $mod+d exec --no-startup-id j4-dmenu-desktop --dmenu='rofi -i -dmenu -p "run:"'
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+b split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
#bar {
#        status_command i3status
#}

bar {
    output            LVDS1
    status_command    i3status -c ~/.i3/i3status.conf
#    status_command    i3blocks -c ~/.i3/i3blocks.conf
    position          bottom
    workspace_buttons yes
    tray_output       primary
    
    font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

    colors {
        background #2f102e
        statusline #ffffff

        focused_workspace  #ffffff #285577
        active_workspace   #ffffff #333333
        inactive_workspace #888888 #222222
        urgent_workspace   #ffffff #900000
    }
}

# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound
# bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute 0 toggle

# Sreen brightness controls
bindsym XF86MonBrightnessUp exec xbacklight -inc 10 # increase screen brightness
bindsym XF86MonBrightnessDown exec xbacklight -dec 10 # decrease screen brightness

# Touchpad controls
bindsym XF86TouchpadToggle exec bash /home/felix/.i3/toggletouchpad.sh # toggle touchpad

# Media player controls
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86WebCam exec pavucontrol

# startup: network manager and toggle touchpad
exec --no-startup-id nm-applet
exec --no-startup-id bash /home/felix/.i3/toggletouchpad.sh
exec --no-startup-id synergy
exec --no-startup-id gtk-redshift
exec --no-startup-id xset dpms 600
exec --no-startup-id xautolock -time 10 -locker lock
exec --no-startup-id rfkill block bluetooth
exec --no-startup-id rfkill block wwan

# shutdown, lock, backlight
bindsym $mod+Shift+p exec systemctl poweroff
bindsym XF86ScreenSaver exec bash /home/felix/.i3/lock.sh
bindsym XF86Battery exec xset dpms force standby

#caps lock -> esc
exec --no-startup-id setxkbmap -layout de -option caps:ctrl_modifier
exec --no-startup-id xcape -e 'Control_L=Escape'

Nautilus Metadaten

#!/usr/bin/python

import os
import urllib
#import nautilus
from gi.repository import Nautilus, GObject, Gtk, GdkPixbuf
# for id3 support
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MPEGInfo
from mutagen.ogg import OggPage, OggFileType
from mutagen.oggvorbis import OggVorbis, OggVorbisInfo, delete
# for exif support
import pyexiv2
# for reading videos. for future improvement, this can also read mp3!
import kaa.metadata
# for reading image dimensions
import Image
# for reading pdf
try:
	from pyPdf import PdfFileReader
except:
	pass

class ColumnExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider):
	def __init__(self):
		pass

	def get_columns(self):
		return (
			Nautilus.Column(name="NautilusPython::title_column",attribute="title",label="Title",description="Song title"),
			Nautilus.Column(name="NautilusPython::album_column",attribute="album",label="Album",description="Album"),
			Nautilus.Column(name="NautilusPython::artist_column",attribute="artist",label="Artist",description="Artist"),
			Nautilus.Column(name="NautilusPython::tracknumber_column",attribute="tracknumber",label="Track",description="Track number"),
			Nautilus.Column(name="NautilusPython::genre_column",attribute="genre",label="Genre",description="Genre"),
			Nautilus.Column(name="NautilusPython::date_column",attribute="date",label="Date",description="Date"),
			Nautilus.Column(name="NautilusPython::bitrate_column",attribute="bitrate",label="Bitrate",description="Audio Bitrate in kilo bits per second"),
			Nautilus.Column(name="NautilusPython::samplerate_column",attribute="samplerate",label="Sample rate",description="Sample rate in Hz"),
			Nautilus.Column(name="NautilusPython::length_column",attribute="length",label="Length",description="Length of audio"),
			Nautilus.Column(name="NautilusPython::exif_datetime_original_column",attribute="exif_datetime_original",label="EXIF Dateshot ",description="Get the photo capture date from EXIF data"),
			Nautilus.Column(name="NautilusPython::exif_software_column",attribute="exif_software",label="EXIF Software",description="EXIF - software used to save image"),
			Nautilus.Column(name="NautilusPython::exif_flash_column",attribute="exif_flash",label="EXIF flash",description="EXIF - flash mode"),
			Nautilus.Column(name="NautilusPython::exif_pixeldimensions_column",attribute="exif_pixeldimensions",label="EXIF Image Size",description="Image size - pixel dimensions as reported by EXIF data"),
			Nautilus.Column(name="NautilusPython::pixeldimensions_column",attribute="pixeldimensions",label="Image Size",description="Image/video size - actual pixel dimensions"),
		)

	def update_file_info(self, file):
		# set defaults to blank
		file.add_string_attribute('title', '')
		file.add_string_attribute('album', '')
		file.add_string_attribute('artist', '')
		file.add_string_attribute('tracknumber', '')
		file.add_string_attribute('genre', '')
		file.add_string_attribute('date', '')
		file.add_string_attribute('bitrate', '')
		file.add_string_attribute('samplerate', '')
		file.add_string_attribute('length', '')
		file.add_string_attribute('exif_datetime_original', '')
		file.add_string_attribute('exif_software', '')
		file.add_string_attribute('exif_flash', '')
		file.add_string_attribute('exif_pixeldimensions', '')
		file.add_string_attribute('pixeldimensions', '')

		if file.get_uri_scheme() != 'file':
			return

		# strip file:// to get absolute path
		filename = urllib.unquote(file.get_uri()[7:])
		
		# mp3 handling
		if file.is_mime_type('audio/mpeg'):
			# attempt to read ID3 tag
			try:
				audio = EasyID3(filename)try: file.add_string_attribute('title', audio["title"][0])
				except: file.add_string_attribute('title', "[n/a]")
				try: file.add_string_attribute('album', audio["album"][0])
				except: file.add_string_attribute('album', "[n/a]")
				try: file.add_string_attribute('artist', audio["artist"][0])
				except: file.add_string_attribute('artist', "[n/a]")
				try: file.add_string_attribute('tracknumber', audio["tracknumber"][0])
				except: file.add_string_attribute('tracknumber', "[n/a]")
				try: file.add_string_attribute('genre', audio["genre"][0])
				except: file.add_string_attribute('genre', "[n/a]")
				try: file.add_string_attribute('date', audio["date"][0])
				except: file.add_string_attribute('date', "[n/a]")
			except:
				# [SabreWolfy] some files have no ID3 tag and will throw this exception:
				file.add_string_attribute('title', "[no ID3]")
				file.add_string_attribute('album', "[no ID3]")
				file.add_string_attribute('artist', "[no ID3]")
				file.add_string_attribute('tracknumber', "[no ID3]")
				file.add_string_attribute('genre', "[no ID3]")
				file.add_string_attribute('date', "[no ID3]")
				
			# try to read MP3 information (bitrate, length, samplerate)
			try:
				mpfile = open (filename)
				mpinfo = MPEGInfo (mpfile)
				file.add_string_attribute('bitrate', str(mpinfo.bitrate/1000) + " Kbps")
				file.add_string_attribute('samplerate', str(mpinfo.sample_rate) + " Hz")mp3length = "%02i:%02i:%02i" % ((int(mpinfo.length/3600)), (int(mpinfo.length/60%60)), (int(mpinfo.length%60)))
				mpfile.close()
				file.add_string_attribute('length', mp3length)
			except:
				file.add_string_attribute('bitrate', "[n/a]")
				file.add_string_attribute('length', "[n/a]")
				file.add_string_attribute('samplerate', "[n/a]")
				try:
					mpfile.close()
				except:	pass
		#ogg handling	
		if file.is_mime_type('audio/ogg'):
			# try to read OGG information (bitrate, length)
			try:
				oggfile = filename
				ogginfo = OggVorbis(str(oggfile))
				file.add_string_attribute('bitrate', str(ogginfo.info.bitrate/1000) + " kbps")ogglength = "%02i:%02i:%02i" % ((int(ogginfo.info.length/3600)), (int(ogginfo.info.length/60%60)), (int(ogginfo.info.length%60)))
				file.add_string_attribute('length', ogglength)
			except:
				file.add_string_attribute('bitrate', "[n/a]")
				file.add_string_attribute('length', "[n/a]")
	
		# image handling
		if file.is_mime_type('image/jpeg') or file.is_mime_type('image/png') or file.is_mime_type('image/gif') or file.is_mime_type('image/bmp'):
			# EXIF handling routines
			try:
				metadata = pyexiv2.ImageMetadata(filename)
				metadata.read()
				exif_datetimeoriginal = metadata['Exif.Photo.DateTimeOriginal']
				exif_imagesoftware = metadata['Exif.Image.Software']
				exif_photoflash = metadata['Exif.Photo.Flash']
				exif_pixelydimension = metadata['Exif.Photo.PixelYDimension']
				exif_pixelxdimension = metadata['Exif.Photo.PixelXDimension']
				file.add_string_attribute('exif_datetime_original',str(exif_datetimeoriginal.raw_value))
				file.add_string_attribute('exif_software',str(exif_imagesoftware.raw_value))
				file.add_string_attribute('exif_flash',str(exif_photoflash.raw_value))
				file.add_string_attribute('exif_pixeldimensions',str(exif_pixelydimension.raw_value)+'x'+str(exif_pixelxdimension.raw_value))
			except:
				# no exif data?
				file.add_string_attribute('exif_datetime_original',"")
				file.add_string_attribute('exif_software',"")
				file.add_string_attribute('exif_flash',"")
				file.add_string_attribute('exif_pixeldimensions',"")
			# try read image info directly
			try:
				im = Image.open(filename)
				file.add_string_attribute('pixeldimensions',str(im.size[0])+'x'+str(im.size[1]))
			except:
				file.add_string_attribute('pixeldimensions',"[image read error]")

		# video/flac handling
		if file.is_mime_type('video/x-msvideo') | file.is_mime_type('video/mpeg') | file.is_mime_type('video/x-ms-wmv') | file.is_mime_type('video/mp4') | file.is_mime_type('audio/x-flac') | file.is_mime_type('video/x-flv') | file.is_mime_type('video/x-matroska') | file.is_mime_type('audio/x-wav'):
			try:
				info=kaa.metadata.parse(filename)
				try: file.add_string_attribute('length',"%02i:%02i:%02i" % ((int(info.length/3600)), (int(info.length/60%60)), (int(info.length%60))))
				except: file.add_string_attribute('length','[n/a]')
				try: file.add_string_attribute('pixeldimensions', str(info.video[0].width) + 'x'+ str(info.video[0].height))
				except: file.add_string_attribute('pixeldimensions','[n/a]')
				try: file.add_string_attribute('bitrate',str(round(info.audio[0].bitrate/1000)))
				except: file.add_string_attribute('bitrate','[n/a]')
				try: file.add_string_attribute('samplerate',str(int(info.audio[0].samplerate))+' Hz')
				except: file.add_string_attribute('samplerate','[n/a]')
				try: file.add_string_attribute('title', info.title)
				except: file.add_string_attribute('title', '[n/a]')
				try: file.add_string_attribute('artist', info.artist)
				except: file.add_string_attribute('artist', '[n/a]')
				try: file.add_string_attribute('genre', info.genre)
				except: file.add_string_attribute('genre', '[n/a]')
				try: file.add_string_attribute('tracknumber',info.trackno)
				except: file.add_string_attribute('tracknumber', '[n/a]')
				try: file.add_string_attribute('date',info.userdate)
				except: file.add_string_attribute('date', '[n/a]')					
				try: file.add_string_attribute('album',info.album)
				except: file.add_string_attribute('album', '[n/a]')
			except:
				file.add_string_attribute('length','error')
				file.add_string_attribute('pixeldimensions','error')
				file.add_string_attribute('bitrate','error')
				file.add_string_attribute('samplerate','error')
				file.add_string_attribute('title','error')
				file.add_string_attribute('artist','error')
				file.add_string_attribute('genre','error')
				file.add_string_attribute('track','error')
				file.add_string_attribute('date','error')
				file.add_string_attribute('album','error')
		# pdf handling
		if file.is_mime_type('application/pdf'):
			try:
				f = open(filename, "rb")
				pdf = PdfFileReader(f)
				try: file.add_string_attribute('title', pdf.getDocumentInfo().title)
				except: file.add_string_attribute('title', "[n/a]")
				try: file.add_string_attribute('artist', pdf.getDocumentInfo().author)
				except: file.add_string_attribute('artist', "[n/a]")
				f.close()
			except:
				file.add_string_attribute('title', "[no info]")
				file.add_string_attribute('artist', "[no info]")
					
		self.get_columns()

Autostart mit Checkboxes

#!/bin/bash
string=$(whiptail --title "Autostart" --checklist \
	"Choose startup applications" 17 32 11 \
	"firefox" "" ON\
	"thunderbird" "" ON \
	"amarok" "" ON \
	"skype" "" ON \
	"eiskaltdcpp-qt" "" ON \
	"weechat" "" ON \
	"pidgin" "" ON \
	"specto" "" ON \
	"liferea" "" ON \
	"synergy" "" ON \
	"dropbox start -i" "" ON 3>&1 1>&2 2>&3)

string=$(echo $string | sed 's/" "/,/g')
string=$(echo $string | sed 's/"//g')

if [ "$(echo $string | grep weechat)" ]; then
	string=$(echo $string | sed 's/weechat//g')
	nohup guake --execute-command="weechat-curses" &
fi

IFS="," read -ra array <<< "$string"

for i in "${array[@]}"; do
	nohup $i >>/dev/null 2>>/dev/null &
done

Soundcloud Downloads

Git

flash-Videos aus dem Browser

...speichern

#!/bin/bash

if [[ `ps x | awk '/libgcflashplayer.so\ /{print $1}'` ]]; then
	flashvids() { lsof -p `ps x | awk '/libgcflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
else
	flashvids() { lsof -p `ps x | awk '/libflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
fi
echo $(flashvids)
cp $(flashvids) ~/Desktop

Für Youtube: youtube-dl aus den Paketquellen.

...mit mplayer abspielen

#!/bin/bash

if [[ `ps x | awk '/libgcflashplayer.so\ /{print $1}'` ]]; then
	flashvids() { lsof -p `ps x | awk '/libgcflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
else
	flashvids() { lsof -p `ps x | awk '/libflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
fi

arr=($(flashvids))

if [[ ${#arr[@]} > 1 ]]; then
	echo "${#arr[@]} videos found. Which should be shown?"
	read show
	mplayer ${arr[($show-1)]}
else
	mplayer ${arr[0]}
fi

Unicrawler ohne Moodle

#!/bin/sh -e

function_load(){
	cd "${1}" && shift && wget --accept pdf,PDF --execute robots=off --continue --level 1 --no-directories --no-verbose --recursive --timestamping --user-agent "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101" "${@}"
}

function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/TDK" \
	--password="*****" \
	"http://dante.phys.chemie.tu-muenchen.de/de/vorlesung/pc1/SS2011/materialienSS2011.html" \


function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/IT II/Vorlesung" \
	--user="VorlesungIT" --password="*****" \
	"http://download.ais.mw.tum.de/IT/index.php?folder=Vm9ybGVzdW5n" \


function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/Bio" \
	--user="Chemiker" --password="******" \
	"ftp://anakin.biotech.ch.tum.de/Chemie/Biologie%20fuer%20Chemiker/" \


function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/HM II/Vorlesung" \
	--user="HM" --password="*****" \
	"http://www.ma.tum.de/HM/MW2SoSe11/Inhalt" \

Onlinefestplatten

#!/bin/bash

########################################################################
#                                                                      #
#                             Funktionen                               #
#                                                                      #
########################################################################

function fqmodus()		#Funktion: Modus abfragen
{
echo "Skript zum Anzeigen, Mounten und Unmounten von Onlinefestplatten"
read -p " Anzeigen (a), Mount (m) oder Unmount (u): " modus
}


function fqplatte()		#Funktion: Platte abfragen
{
echo "Zur Auswahl stehen geekbox, ownCloud, t-online und MWN"
read -p " Gib die gewünschte Platte ein: " platte
}


function fqnochmal()		#Funktion: Abfrage ob nochmal
{
read -p " Fertig? (y/n) " fertig
if [ "$fertig" == "y" ]; then return 1; fi
}


function fanzeigen()		#Funktion: eingehängte Platten anzeigen
{
if [ "$(df -h | grep 'geekbox\|ownCloud\|t-online\|MWN')" ]; then
	df -h | grep 'geekbox\|ownCloud\|t-online\|MWN'
else
	echo "Kein Verzeichnis eingehängt"
fi
}


function fpruef()		#Funktion: Prüfen, ob Mountpoint belegt
{
if [ "$(df | grep $1)" ]; then
	echo "Warnung: $1 ist bereits eingehängt"
	read -p " Trotzdem einhängen? (y/n) " trotzdem
	if [ "$trotzdem" == "y" ]; then return 0;	fi
	return 1
fi
return 0
}


function ftest()		#Funktion: Testen, ob wirklich ein/ausgehängt
{
case "$1" in
	m)
		if [ "$(df | grep $2)" ]; then
			echo "$2 erfolgreich eingehängt"
		else
			echo "$2 wurde nicht eingehängt"
		fi
		;;
	u)
		if [ "$(df | grep $2)" ]; then
			echo "$2 wurde nicht ausgehängt"
		else
			echo "$2 erfolgreich ausgehängt"
		fi
		;;
esac
}


function fmount()		#Funktion: Einhängen
{
case "$platte" in
	geekbox|g)					#geekbox einhängen
		if fpruef /media/geekbox; then
			nohup sshfs <username>@geekbox.info:/ /media/geekbox > /dev/null 2>&1
			ftest $modus /media/geekbox
		fi
		;;
	ownCloud|o)					#ownCloud einhängen
		if fpruef /media/ownCloud; then
			nohup sudo mount -t davfs -o username=<username> <Adresse unter ownCloud->Einstellungen->Persönlich zu finden> /media/ownCloud > /dev/null 2>&1
			ftest $modus /media/ownCloud
		fi
		;;
	t-online|t)					#t-online einhängen
		if fpruef /media/t-online; then
			nohup sudo mount -t davfs -o username=<username> https://webdav.mediencenter.t-online.de/ /media/t-online > /dev/null 2>&1
			ftest $modus /media/t-online
		fi
		;;
	MWN|mwn|M|m)					#MWN einhängen
		if fpruef /media/MWN; then
			if ! [ "$(ps ax | grep vpnc | grep -v grep)" ]; then	#Prüfen, ob eine VPN-Verbindung zum MWN besteht
				echo "Es besteht keine VPN-Verbindung zum MWN. Diese wird jetzt aufgebaut."
				nohup sudo vpnc <entsprechnde vpnc.conf> > /dev/null 2>&1		#VPN-Verbindung zum MWN herstellen
			fi
			nohup sudo mount -t cifs -o username=<LRZ-Kennung>,domain=ADS //nas.ads.mwn.de/<LRZ-Kennung> /media/MWN > /dev/null 2>&1
			ftest $modus /media/MWN
		fi
		;;
	*)						#Fehleingabe abfangen
		echo $platte "steht nicht zur Auswahl!"
		;;
esac
}


function funmount()		#Funktion: Aushängen
{
case "$platte" in
	geekbox|g)					#geekbox aushängen
		fusermount -u /media/geekbox
		ftest $modus /media/geekbox
		;;
	ownCloud|owncloud|o)				#ownCloud aushängen
		sudo umount /media/ownCloud
		ftest $modus /ownCloud
		;;
	t-online|t)					#t-online aushängen
		sudo umount /media/t-online
		ftest $modus /media/t-online
		;;
	MWN|mwn|M|m)					#MWN aushängen
		sudo umount /media/MWN
		ftest $modus /media/MWN
		;;
	*)						#Fehleingabe abfangen
		echo $platte "steht nicht zur Auswahl!"
		;;
esac
}



########################################################################
#                                                                      #
#                               Main                                   #
#                                                                      #
########################################################################

while true; do
	clear
	fqmodus					#Modus abfragen

	case "$modus" in 
		a)
			fanzeigen		#Anzeigen
			;;
		m)
			fqplatte		#Platte abfragen
			fmount			#Einhängen
			;;
		u)
			fqplatte		#Platte abfragen
			funmount		#Aushängen
			;;
		*)
			echo "Dieser Modus steht nicht zur Auswahl!"	#Falscheingaben
			;;
	esac

	if ! fqnochmal; then break; fi		#Nochmal von vorne?
done

clear

altes Minecraft-über-Hamachi-Skript

#!/bin/bash

########################################################################
#                                                                      #
#                           Konfiguration                              #
#                                                                      #
########################################################################

#IP des Servers
IP="<IP>"
#DynDns des Servers
DNS="<DynDns>"
#Hamachi Netzwerkname
HAHACHI="<Netzwerkname>"
#Zeit zwischen den Pings
PAUSE=3
#wie viele Fehler vor reconnect
TOLERANZ=2




########################################################################
#                                                                      #
#                           DynDNS testen                              #
#                                                                      #
########################################################################

if ping -c 1 -w 1 $DNS > /dev/null; then
	DYNDNS=true
else 
	DYNDNS=false
fi


########################################################################
#                                                                      #
#                           Spiel starten                              #
#                                                                      #
########################################################################

if $DYNDNS; then
	echo "************ DynDNS verwenden:" $DNS "************"
else
	echo "************ Hamachi verwenden:" $IP "************"
	if ! ping -c 1 -w 1 $IP > /dev/null; then
		gksudo tuncfg
		hamachi go-offline $HAHACHI
		hamachi logout
		hamachi stop
		hamachi start
		hamachi login
		hamachi go-online $HAHACHI
		hamachi get-nicks
		#hamachi list
	fi
fi

java -jar <Pfad>/minecraft.jar &



########################################################################
#                                                                      #
#                     Verbindungsüberwachung                           #
#                                                                      #
########################################################################

sleep 10
FEHLER=0
if $DYNDNS; then 
	while true; do
		if ! ping -c 1 -w 1 $DNS > /dev/null; then
			FEHLER=$((FEHLER+1))
		else
			FEHLER=0
		fi
		if [ $FEHLER -eq $TOLERANZ ]; then
			echo "************ DynDNS-Verbindung unterbrochen ************"
			FEHLER=0
		fi
		sleep $PAUSE
	done
else
	while true; do
		if ! ping -c 1 -w 1 $IP > /dev/null; then
			FEHLER=$((FEHLER+1))
		else
			FEHLER=0
		fi
		if [ $FEHLER -eq $TOLERANZ ]; then
			echo "************ Hamachi-Verbindung unterbrochen -> reconnecting ************"
			gksudo tuncfg
			hamachi go-offline $HAHACHI
			hamachi logout
			hamachi stop
			hamachi start
			hamachi login
			hamachi go-online $HAHACHI
			hamachi get-nicks
			#hamachi list
		fi
		sleep $PAUSE
	done
fi