diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-01-08 11:37:23 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-01-08 11:37:23 +0100 |
commit | b5593ec19bf693c55e35f88bbce7b45a1381d986 (patch) | |
tree | 35e067becdedc71a10b70656bc6c9dac3f2d20e6 | |
download | helper-scripts-b5593ec19bf693c55e35f88bbce7b45a1381d986.tar.gz helper-scripts-b5593ec19bf693c55e35f88bbce7b45a1381d986.tar.xz helper-scripts-b5593ec19bf693c55e35f88bbce7b45a1381d986.zip |
added some usefull scripts
bin/Xshutdown.sh - graphical script for shutdown/reboot/standby
sbin/set_governor - set the governor of both cpus
sbin/keyword_package - adds a package to /etc/portage/packages.keywords
sbin/asound_backup.sh - creates a backup of /etc/asound.conf
sbin/asound_pulse_disable.sh - removes the default references to pulse
sbin/asound_pulse_enable.sh - adds pcm.!default und ctl.!default references to pulse
-rwxr-xr-x | bin/Xshutdown.sh | 34 | ||||
-rwxr-xr-x | sbin/asound_backup.sh | 11 | ||||
-rwxr-xr-x | sbin/asound_pulse_disable.sh | 8 | ||||
-rwxr-xr-x | sbin/asound_pulse_enable.sh | 26 | ||||
-rwxr-xr-x | sbin/keyword_package | 26 | ||||
-rwxr-xr-x | sbin/set_governor | 37 |
6 files changed, 142 insertions, 0 deletions
diff --git a/bin/Xshutdown.sh b/bin/Xshutdown.sh new file mode 100755 index 0000000..eeae1ba --- /dev/null +++ b/bin/Xshutdown.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# export Display for GUI +export DISPLAY=":0.0" + +# Use as shutdown +SHUTDOWN=/sbin/shutdown + +case "$1" in + shutdown) + Xdialog --title Shutdown --center --beep --yesno "Really shutdown the system?" 0 0 \ + && (sync ; exec ${SHUTDOWN} -h now) + ;; + reboot) + Xdialog --title Reboot --center --beep --yesno "Do you want to reboot the system?" 0 0 \ + && (sync ; exec ${SHUTDOWN} -r now) + ;; + standby) + Xdialog -title Standby --center --beep --yesno "Do you want to suspend to ram?" 0 0 \ + && (sync ; exec hibernate-ram ) + ;; + ask) + CHOICE=$(Xdialog --stdout --title 'Choose!' --menubox 'Choose your destiny!' 10 50 3 \ + standby "Suspend to ram." \ + shutdown "Shutdown your system." \ + reboot " Reboot this system.") + [ -z "$CHOICE" ] && exit 1 + exec $0 $CHOICE + ;; + *) + echo $1 + echo 1>&2 "$0 (shutdown|reboot|standby|ask)" + exit 1 + ;; +esac diff --git a/sbin/asound_backup.sh b/sbin/asound_backup.sh new file mode 100755 index 0000000..0e7912e --- /dev/null +++ b/sbin/asound_backup.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "`ls /etc/asound/ | wc -l`" -lt 10 ] +then + for i in `seq 0 9` + do + touch "/etc/asound/asound.conf.bak_${i}" + done +fi + +cat /etc/asound.conf > /etc/asound/"`ls -rt /etc/asound/ | head -n 1`" diff --git a/sbin/asound_pulse_disable.sh b/sbin/asound_pulse_disable.sh new file mode 100755 index 0000000..ff929e2 --- /dev/null +++ b/sbin/asound_pulse_disable.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +asound_backup.sh + +tmp_file="`mktemp`" +echo "`cat /etc/asound.conf` +" | sed "/pcm.\!default/,/}/{H;d};/ctl.\!default/,/}/{H;d};x;/\n[^#\n]*pcm.\!default.*\n[^#\n]*type pulse.*\n[^#\n]*\}/{d};/\n[^#\n]*ctl.\!default.*\n[^#\n]*type pulse.*\n[^#\n]*\}/{d}" > $tmp_file +cat -s $tmp_file > /etc/asound.conf diff --git a/sbin/asound_pulse_enable.sh b/sbin/asound_pulse_enable.sh new file mode 100755 index 0000000..c3d0cae --- /dev/null +++ b/sbin/asound_pulse_enable.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +asound_backup.sh + +tmpfile=`mktemp` +if [ -z "`grep "^[^#]*ctl.\!default" /etc/asound.conf`" ] +then + echo "ctl.!default { + type pulse +} +" > $tmpfile + + cat -s /etc/asound.conf >> $tmpfile + cat -s "$tmpfile" > /etc/asound.conf +fi + +if [ -z "`grep "^[^#]*pcm.\!default" /etc/asound.conf`" ] +then + echo "pcm.!default { + type pulse +} +" > $tmpfile + + cat -s /etc/asound.conf >> $tmpfile + cat -s "$tmpfile" > /etc/asound.conf +fi diff --git a/sbin/keyword_package b/sbin/keyword_package new file mode 100755 index 0000000..93b93d9 --- /dev/null +++ b/sbin/keyword_package @@ -0,0 +1,26 @@ +#!/bin/sh +SPECIAL_LINE_COUNT=$(grep -nE "(/\*)|(\*/)" /etc/portage/package.keywords | tail -n 1 | awk -F: '{ print $1 }') +TMP_FILE=$(mktemp) + +head -n $SPECIAL_LINE_COUNT /etc/portage/package.keywords > $TMP_FILE + +( + while [ -n "${1}" ] ; do + LINE="${1} ~x86" + if [ -z "$(grep "^${LINE}$" /etc/portage/package.keywords)" ] + then + echo "${LINE}" + echo "adding \"${LINE}\" to /etc/portage/package.keywords" | logger -st $(basename $0) + else + echo "Don't adding \"${1}\". Already there." > /dev/stderr + fi + + shift 1 + done + + tail -n $(($(cat /etc/portage/package.keywords | wc -l)-$SPECIAL_LINE_COUNT)) /etc/portage/package.keywords +) | grep -v "^$" | sort | awk -F/ '{ if (OLD_PREFIX!=$1) print ""; OLD_PREFIX=$1 ; print }' >> $TMP_FILE + +mv /etc/portage/package.keywords /etc/portage/package.keywords.bak +mv $TMP_FILE /etc/portage/package.keywords +chmod +r /etc/portage/package.keywords diff --git a/sbin/set_governor b/sbin/set_governor new file mode 100755 index 0000000..08f68e5 --- /dev/null +++ b/sbin/set_governor @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Script to display and set (checked) the governors for the both CPU Cores (f.e. from the Core2Duo) +# (c) Alexander Sulfrian 2007 +# Licence: GPL v3 +# + + +if [ -z "$1" ] +then + activ_governor_cpu0=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` + activ_governor_cpu1=`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor` + echo "active governors" + echo "CPU 0: ${activ_governor_cpu0}" + echo "CPU 1: ${activ_governor_cpu1}" + exit 1 +fi + + +governor_avalible=`sed 's/ \(.\)/\n\1/g;s/ $//g' /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | grep "^${1}\$"` +if [ -z "$governor_avalible" ] +then + avalible_governors=`sed 's/ \(.\)/|\1/g;s/ $//g' /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors` + echo "Usage:" + echo "$0 [${avalible_governors}]" + exit 2 +fi + +echo "$1" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor +echo "$1" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + +activ_governor_cpu0=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` +activ_governor_cpu1=`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor` +echo "active governors" +echo "CPU 0: ${activ_governor_cpu0}" +echo "CPU 1: ${activ_governor_cpu1}" +exit 0 |