deskmnngr upd

master
Daniel Napora 2021-05-31 15:05:05 +02:00
parent 3d81bc66ba
commit 869d6238f9
1 changed files with 25 additions and 6 deletions

View File

@ -1,10 +1,11 @@
#!/bin/bash
# Copyright (C) Daniel Napora 2021 <napcok@gmail.com>
#: deskmngr - save all programs (windows) running on current desktop in session file.
#: With windows positions and state (decorated or not)
#: With windows positions and state (decorated or not)
#: Usage:
#: -s|save - save session from current desktop
#: -r|restore sesionfile desktop_ID - restore session from sessionfile on desktop
#: -l|listsessions - list saved sessions
#: -s|save - save session from current desktop
#: -r|restore sesionfile desktop_ID - restore session from sessionfile on desktop
#:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,11 +23,26 @@
SESSIONDIR="$HOME/.config/deskmngr/"
mkdir -p $SESSIONDIR
case "$LANG" in
pl*)
TITLE="Nie ma nic do zapisania"
TEXT="\nWygląda na to że nie ma otwartych okien na bieżącym pulpicie.\nUruchom jakieś programy i spróbuj ponownie.\n"
SAVE_AS="Zapisz sesję jako:"
SESSNAME="Nazwa sesji"
;;
*)
TITLE="Nothing to save"
TEXT="\nLooks like there are no windows to save on current desktop.\n Run some programs and try again.\n"
SAVE_AS="Save session as:"
SESSNAME="Session name"
;;
esac
savesession() {
curdesk=$(wmctrl -d | grep "*" | awk '{print $1}')
if [ $(wmctrl -l -p -G | awk -v c=$curdesk '$2 == c {print $2}' | wc -l) == "0" ];then notify-send -i dialog-warning "Nothing to save" "\nStart some programs and try again.\n";exit 1;fi
if [ $(wmctrl -l -p -G | awk -v c=$curdesk '$2 == c {print $2}' | wc -l) == "0" ];then notify-send -i dialog-warning "$TITLE" "$TEXT";exit 1;fi
filename=$(yad --center --title "Save session as:" --entry --entry-label="Session name" --entry-text="Session name") || exit 1
filename=$(yad --center --title "$SAVE_AS" --entry --entry-label="$SESSNAME" --entry-text="$SESSNAME") || exit 1
windows=()
wmctrl -l -p -G | {
while IFS= read -r line
@ -47,7 +63,7 @@ savesession() {
fi
done
if [ ${#windows[@]} -eq 0 ]; then
notify-send -i dialog-warning "Nothing to save" "Opps, looks like there are no windows to save on current desktop.\n Run some programs and try again ;)"
notify-send -i dialog-warning "$TITLE" "$TEXT"
else
printf "%s\n" "${windows[@]}" > "$SESSIONDIR/${filename// /_}.desk"
# Serch replace
@ -96,6 +112,9 @@ restoresession() {
done
}
}
overwrite() {
echo "Not implemented"
}
listsessions() {
ls -1 ${SESSIONDIR}