Help manage multiple Yakuake sessions using ysess
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ysess-manager/ysm.sh

77 lines
1.3 KiB

#!/bin/bash
name="ysess-manager"
version=0.1.0
author="Joe <joe@thisisjoes.site>"
license="GNU GPLv3"
declare -A config
config=(
[extension]="ysess"
[name]="last.$extension"
[format]="+%d%m%Y_%H%M%S"
[action]="increment"
[path]="$HOME/.ysess"
[s_path]="$HOME/.ysess/*.ysess"
)
while read line
do
if echo $line | grep -F = &>/dev/null
then
varname=$(echo "$line" | cut -d '=' -f 1)
config[$varname]=$(echo "$line" | cut -d '=' -f 2-)
fi
done < ${config[path]}/ysm.conf
CreateFiles() {
if [ ! -d "$default_path" ]; then
mkdir $HOME/.ysess
touch $HOME/.ysess/last.name
fi
}
CreateArray() {
sessions=(${config[s_path]})
}
UserInput() {
read -r -p "$(echo -e '\e[4mL\e[0moad/\e[4mS\e[0mave: ')" task
}
CallTask() {
case "$task" in
[Ll] ) LoadSession;;
[Ss] ) SaveSession;;
* ) InvalidInput;;
esac
}
LoadSession() {
for ((i=0;i<"${#sessions[*]}";i++)); do
echo -n "[$i] "
echo "$(basename "${sessions[$i]}" .ysess)"
done
}
Debug() {
echo Debug Enabled!
echo Sessions: $default_s_path
echo Total: ${#sessions[*]}
echo Extension: ${config[extension]}
echo Name: ${config[name]}
echo Format: ${config[format]}
echo Action: ${config[action]}
echo Path: ${config[path]}
echo S-Path: "${config[s_path]}"
}
Main() {
CreateFiles
CreateArray
Debug
UserInput
CallTask
}
Main