deskmnngr upd
parent
3d81bc66ba
commit
869d6238f9
31
bin/deskmngr
31
bin/deskmngr
|
@ -1,10 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (C) Daniel Napora 2021 <napcok@gmail.com>
|
# Copyright (C) Daniel Napora 2021 <napcok@gmail.com>
|
||||||
#: deskmngr - save all programs (windows) running on current desktop in session file.
|
#: 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:
|
#: Usage:
|
||||||
#: -s|save - save session from current desktop
|
#: -l|listsessions - list saved sessions
|
||||||
#: -r|restore sesionfile desktop_ID - restore session from sessionfile on desktop
|
#: -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,11 +23,26 @@
|
||||||
SESSIONDIR="$HOME/.config/deskmngr/"
|
SESSIONDIR="$HOME/.config/deskmngr/"
|
||||||
mkdir -p $SESSIONDIR
|
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() {
|
savesession() {
|
||||||
curdesk=$(wmctrl -d | grep "*" | awk '{print $1}')
|
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=()
|
windows=()
|
||||||
wmctrl -l -p -G | {
|
wmctrl -l -p -G | {
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
|
@ -47,7 +63,7 @@ savesession() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ${#windows[@]} -eq 0 ]; then
|
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
|
else
|
||||||
printf "%s\n" "${windows[@]}" > "$SESSIONDIR/${filename// /_}.desk"
|
printf "%s\n" "${windows[@]}" > "$SESSIONDIR/${filename// /_}.desk"
|
||||||
# Serch replace
|
# Serch replace
|
||||||
|
@ -96,6 +112,9 @@ restoresession() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
overwrite() {
|
||||||
|
echo "Not implemented"
|
||||||
|
}
|
||||||
|
|
||||||
listsessions() {
|
listsessions() {
|
||||||
ls -1 ${SESSIONDIR}
|
ls -1 ${SESSIONDIR}
|
||||||
|
|
Loading…
Reference in New Issue