From ef6c37e43e27e4a97239df57b1f1a39adae4c848 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 27 Dec 2013 12:42:57 +0100 Subject: [PATCH] Fix new session creation. --- bin/kotam | 32 ++++++++++++++++++++------------ lib/base.sh | 3 ++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/kotam b/bin/kotam index 5bc1ece..1bbe23d 100755 --- a/bin/kotam +++ b/bin/kotam @@ -22,23 +22,27 @@ kotam_fail(){ } kotam_project_list() { + local tmppwd=$(pwd) echo "List of projects :" - ls $KOTAM_CONFIG_DIR/*.kotam 2> /dev/null + cd $KOTAM_CONFIG_DIR + find -maxdepth 1 -mindepth 1 -name '*.kotam' |sed -e 's|./| |' -e 's/.kotam$//' + cd $tmppwd +} + +kotam_project_ensure() { + if [ ! -e "$KOTAM_CONFIG_DIR/$PROJECT.kotam" ]; then + kotam_fail "unknown project $PROJECT" >&2 + fi } kotam_project_edit() { - if [ ! -e "$KOTAM_CONFIG_DIR/$project.kotam" ]; then - kotam_fail "unknown project $project" >&2 - fi - "$EDITOR" "$KOTAM_CONFIG_DIR/$project.kotam" + kotam_project_ensure + "$EDITOR" "$KOTAM_CONFIG_DIR/$PROJECT.kotam" } kotam_project_run(){ - project="$arg" - if [ ! -e "$KOTAM_CONFIG_DIR/$project.kotam" ]; then - kotam_fail "unknown project $project" >&2 - fi - . "$KOTAM_CONFIG_DIR/$project.kotam" + kotam_project_ensure + . "$KOTAM_CONFIG_DIR/$PROJECT.kotam" } ACTION="" @@ -78,6 +82,7 @@ while [ $# -gt 0 ]; do ;; *) #enter into project ACTION="run" + PROJECT="$arg" ;; esac shift @@ -88,14 +93,17 @@ case "$ACTION" in kotam_project_list ;; create) - kotam__project_create + kotam_project_create ;; edit) - kotam__project_edit + kotam_project_edit ;; delete) kotam_project_delete ;; + run) + kotam_project_run + ;; *) kotam_fail "undefined action $ACTION" ;; diff --git a/lib/base.sh b/lib/base.sh index 570cf60..951437f 100644 --- a/lib/base.sh +++ b/lib/base.sh @@ -11,7 +11,8 @@ kotam_newtab() { #dbus-send --session --dest=${KONSOLE_DBUS_SERVICE} --type=method_call \ # --print-reply /konsole/MainWindow_1 org.kde.KMainWindow.activateAction string:"new-tab" - session=$(qdbus org.kde.konsole /Konsole newSession) + TARGET=${KONSOLE_DBUS_SERVICE:-org.kde.konsole} + session=$(qdbus $TARGET /Konsole newSession) } kotam_renametab() {