From 13f72c131aad14b7c6135fdbae4006d91c5a9607 Mon Sep 17 00:00:00 2001 From: Roberto Previdi Date: Mon, 4 May 2009 03:25:53 +0200 Subject: [PATCH] added some scripts --- menu/git/git_add | 4 ++++ menu/git/git_push | 4 ++++ menu/git/git_status | 4 ++++ menu/system/alsamixer | 4 ++++ menu/system/d | 0 menu/system/e | 0 menu/system/man | 6 ++++++ scripta | 41 +++++++++++++++++++++-------------------- scripta => scripta~ | 35 ++++++++++++++++++----------------- 9 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 menu/git/git_add create mode 100644 menu/git/git_push create mode 100644 menu/git/git_status create mode 100644 menu/system/alsamixer delete mode 100644 menu/system/d delete mode 100644 menu/system/e create mode 100644 menu/system/man copy scripta => scripta~ (90%) mode change 100755 => 100644 diff --git a/menu/git/git_add b/menu/git/git_add new file mode 100644 index 0000000..df8abef --- /dev/null +++ b/menu/git/git_add @@ -0,0 +1,4 @@ +function run() +{ + $MSGBOX "edit me!" +} diff --git a/menu/git/git_push b/menu/git/git_push new file mode 100644 index 0000000..e1732a9 --- /dev/null +++ b/menu/git/git_push @@ -0,0 +1,4 @@ +function run() +{ + git push git+ssh://hariseldon78@repo.or.cz/srv/git/scripta.git master | $ZENITY --text-info +} diff --git a/menu/git/git_status b/menu/git/git_status new file mode 100644 index 0000000..c080c4e --- /dev/null +++ b/menu/git/git_status @@ -0,0 +1,4 @@ +function run() +{ + git status | $ZENITY --text-info +} diff --git a/menu/system/alsamixer b/menu/system/alsamixer new file mode 100644 index 0000000..3597ba2 --- /dev/null +++ b/menu/system/alsamixer @@ -0,0 +1,4 @@ +function run() +{ + alsamixer +} diff --git a/menu/system/d b/menu/system/d deleted file mode 100644 index e69de29..0000000 diff --git a/menu/system/e b/menu/system/e deleted file mode 100644 index e69de29..0000000 diff --git a/menu/system/man b/menu/system/man new file mode 100644 index 0000000..56eb9a6 --- /dev/null +++ b/menu/system/man @@ -0,0 +1,6 @@ +function run() +{ + TERM=gnome-terminal + COMMAND=$($ENTRY "which command?") + $TERM -x man $COMMAND & +} diff --git a/scripta b/scripta index 7e0c0b0..b14e236 100755 --- a/scripta +++ b/scripta @@ -22,7 +22,7 @@ function change_dir() function new_menu() { - NAME="$($ENTRY "enter the name of the menu")" + NAME="$($ENTRY "enter the name of the menu" | sed 's/ /_/')" if [ $? -gt 0 ]; then $MSGBOX operation cancelled else @@ -32,7 +32,7 @@ function new_menu() function new_script() { - NAME="$($ENTRY "enter the name of the script")" + NAME="$($ENTRY "enter the name of the script"| sed 's/ /_/')" if [ $? -gt 0 ]; then $MSGBOX operation cancelled else @@ -41,13 +41,24 @@ function new_script() cat >> "$NAME" << _END function run() { - $MSGBOX "edit me!" + \$MSGBOX "edit me!" } _END # ---> # fi } +#arg1: the file/dir to rename +function rename_file() +{ + NEW_NAME=$($ZENITY --entry --text "enter new name" --entry-text $1) + if [ $? -gt 0 ]; then + $MSGBOX operation cancelled + else + mv $1 $NEW_NAME + fi +} + #arg1: menu to edit function edit_menu() { @@ -57,17 +68,12 @@ function edit_menu() elif [ "$ACTION" == "remove" ]; then PASSWORD=$($ZENITY --entry --text "enter \"DELETE this MENU\"" --entry-text "pleeease, don't kill meeee") if [ $? -gt 0 -o $PASSWORD != "DELETE this MENU"]; then - $MSGBOX operation cancelled + $MSGBOX "operation cancelled" else rm -rf $1 fi elif [ "$ACTION" == "rename" ]; then - NEW_NAME=$($ENTRY "enter new name" --entry-text $1) - if [ $1 -gt 0 ]; then - $MSGBOX operation cancelled - else - mv $1 $NEW_NAME - fi + rename_file $1 fi } @@ -76,25 +82,20 @@ function edit_file() { ACTION=$($ZENITY --column "Select action" --list edit rename remove) if [ $? -gt 0 ]; then - $MSGBOX operation cancelled + $MSGBOX "operation cancelled" elif [ "$ACTION" == "edit" ]; then - $EDITFILE $1 > $1.tmp + $EDITFILE $1 --title $1 > $1.tmp mv -f $1.tmp $1 elif [ "$ACTION" == "remove" ]; then PASSWORD="$($ZENITY --entry --text "enter \"DELETE this FILE\"" --entry-text "noooo, save meeee")" if [ $? -gt 0 -o $PASSWORD != "DELETE this FILE"]; then - $MSGBOX operation cancelled + $MSGBOX "operation cancelled" else rm -rf $1 fi elif [ "$ACTION" == "rename" ]; then - NEW_NAME=$($ZENITY --entry --text "enter new name" --entry-text $1) - if [ $? -gt 0 ]; then - $MSGBOX operation cancelled - else - mv $1 $NEW_NAME - fi + rename_file $1 fi } @@ -130,7 +131,7 @@ function execute() $ERROR "Error, the file doesn't define a run() function" } - . $1 + source ./$1 run diff --git a/scripta b/scripta~ old mode 100755 new mode 100644 similarity index 90% copy from scripta copy to scripta~ index 7e0c0b0..b32a8c5 --- a/scripta +++ b/scripta~ @@ -22,7 +22,7 @@ function change_dir() function new_menu() { - NAME="$($ENTRY "enter the name of the menu")" + NAME="$($ENTRY "enter the name of the menu" | sed 's/ /_/')" if [ $? -gt 0 ]; then $MSGBOX operation cancelled else @@ -32,7 +32,7 @@ function new_menu() function new_script() { - NAME="$($ENTRY "enter the name of the script")" + NAME="$($ENTRY "enter the name of the script"| sed 's/ /_/')" if [ $? -gt 0 ]; then $MSGBOX operation cancelled else @@ -41,13 +41,24 @@ function new_script() cat >> "$NAME" << _END function run() { - $MSGBOX "edit me!" + \$MSGBOX "edit me!" } _END # ---> # fi } +#arg1: the file/dir to rename +function rename_file() +{ + NEW_NAME=$($ZENITY --entry --text "enter new name" --entry-text $1) + if [ $? -gt 0 ]; then + $MSGBOX operation cancelled + else + mv $1 $NEW_NAME + fi +} + #arg1: menu to edit function edit_menu() { @@ -62,12 +73,7 @@ function edit_menu() rm -rf $1 fi elif [ "$ACTION" == "rename" ]; then - NEW_NAME=$($ENTRY "enter new name" --entry-text $1) - if [ $1 -gt 0 ]; then - $MSGBOX operation cancelled - else - mv $1 $NEW_NAME - fi + rename_file $1 fi } @@ -76,7 +82,7 @@ function edit_file() { ACTION=$($ZENITY --column "Select action" --list edit rename remove) if [ $? -gt 0 ]; then - $MSGBOX operation cancelled + $MSGBOX "operation cancelled" elif [ "$ACTION" == "edit" ]; then $EDITFILE $1 > $1.tmp mv -f $1.tmp $1 @@ -89,12 +95,7 @@ function edit_file() fi elif [ "$ACTION" == "rename" ]; then - NEW_NAME=$($ZENITY --entry --text "enter new name" --entry-text $1) - if [ $? -gt 0 ]; then - $MSGBOX operation cancelled - else - mv $1 $NEW_NAME - fi + rename_file $1 fi } @@ -130,7 +131,7 @@ function execute() $ERROR "Error, the file doesn't define a run() function" } - . $1 + source ./$1 run -- 2.11.4.GIT