]> gitweb.fluxo.info Git - utils-x11.git/commitdiff
Feat: support for selecting only some programs in a session
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 22 Aug 2020 18:09:09 +0000 (15:09 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 22 Aug 2020 18:09:09 +0000 (15:09 -0300)
session

diff --git a/session b/session
index 3cca7a2a59eba1599e645d4b5eb64627f997dfe5..fdb475055d9f868e07e4484784f54853686c1871 100755 (executable)
--- a/session
+++ b/session
@@ -25,6 +25,14 @@ function __session_not_ignored {
     return 1
   fi
 
+  if [ ! -z "$UNIGNORE" ]; then
+    if [ "$UNIGNORE" == "$1" ]; then
+      return 0
+    else
+      return 1
+    fi
+  fi
+
   return 0
 }
 
@@ -143,11 +151,14 @@ function __session_chooser {
   __session_list
   read -rep "Choose session: " n
 
-  if [ ! -z "$n" ]; then
-    session="$(__session_list | grep -E "(^$n.| $n:)" | sed -e "s/^[0-9]*. //" | cut -d : -f 1)"
+  local name="`echo $n | awk '{ print $1 }'`"
+  local program="`echo $n | awk '{ print $2 }'`"
+
+  if [ ! -z "$name" ]; then
+    session="$(__session_list | grep -E "(^$name.| $name:)" | sed -e "s/^[0-9]*. //" | cut -d : -f 1)"
 
     if [ ! -z "$session" ]; then
-      __session_open $session
+      __session_open $session $program
     fi
   fi
 }
@@ -169,6 +180,11 @@ function __session_exec {
 # Open a session
 function __session_open {
   local session="$1"
+  local program="$2"
+
+  if [ ! -z "$program" ]; then
+    UNIGNORE="$program"
+  fi
 
   # Custom
   if __session_not_ignored custom && [ -e "$CUSTOM/$session" ]; then
@@ -239,7 +255,7 @@ elif [ ! -z "$1" ] && echo "$1" | grep -q -- '--list'; then
 elif [ ! -z "$1" ] && echo "$1" | grep -q -- '--chooser'; then
   __session_chooser
 elif [ -z "$1" ]; then
-  echo "usage: $BASENAME [--list|--chooser] <session>"
+  echo "usage: $BASENAME [--list|--chooser] <session> <program>"
   echo "available sessions:"
   echo ""
   __session_list