Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Igrom committed Mar 26, 2018
1 parent d6942bd commit e501b7c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 85 deletions.
50 changes: 16 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,42 @@ i3-persist(1)
=============
[![Build Status](https://travis-ci.org/Igrom/i3-persist.svg?branch=master)](https://travis-ci.org/Igrom/i3-persist)

NAME
Name
----
i3-persist - extends i3 window management with persistent containers


SYNOPSIS
Synopsis
--------
i3-persist lock [\<id>]
i3-persist lock|unlock|toggle|kill [\<id>]

i3-persist unlock [\<id>]

i3-persist toggle [\<id>]

i3-persist kill [\<id>]


DESCRIPTION
Description
-----------
Closes a container or switches its state from closable to persistent.

Using the featured set of commands, containers can be marked so as to prevent their careless closing. A custom kill command is made available as a plug-in substitute for 'i3-msg kill'. If a container is marked as persistent, attempted closing of the container through the command will have no effect.

By default, i3-persist will operate on the currently focused container. For scripting purposes, it is possible to pass a con\_id to all methods.

INSTALLATION NOTES
More information about the tool, as well as up-to-date information about the specific commands can be found in the man page found in the doc directory.

Installation notes
------------------
1. Download the repository and save in a catalog.
Package prerequisites:
- jq
- shunit2 (for unit testing)

1. Copy the repository to your machine.
2. (Optional) Run tests with `./run_tests.sh`.
3. Create a symlink to bin/i3-persist in your PATH.
3. Create a symlink to bin/i3-persist in your $PATH.
4. Copy the contents of the doc directory to a suitable directory (e.g., /usr/local/man or elsewhere along your $MANPATH, if variable exists).

The tool is the most convenient when used with keybindings.

Example .config/i3/config bindings:
- bindsym $mod+Shift+q exec 'i3-persist kill'
- bindsym $mod+Delete exec 'i3-persist toggle'


SUBCOMMANDS
-----------

`lock`
Marks the container as persistent. Prevent subsequent closes.

`unlock`
Marks the container as closable. Allows the container to be closed.

`toggle`
Toggle the container between the two states.

`kill`
Closes the container unless either the container or any of its descending containers are locked. Otherwise, doesn't do anything.

By default, i3-persist will operate on the currently focused container. For scripting purposes, it is possible to pass a con\_id to all methods.


COPYRIGHT
Copyright
---------
Copyright © 2018 Igor Sowinski. Licensed under the 3-clause BSD license.
41 changes: 38 additions & 3 deletions bin/i3-persist.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#!/bin/sh

# i3-persist 0 extends i3 window management with persistent containers
VERSION=1.0.3
FILE="`readlink -f "$0"`"

print_version () {
echo "i3-persist version $VERSION"
}

print_help () {
echo "Syntax: i3-persist [lock|unlock|toggle|kill] [id]"
}

print_invalid () {
printf "i3-persist: invalid operand\nTry 'i3-persist --help' for more information.\n"
}

# import library
. "`dirname $FILE`/../src/i3-persist-common.sh"

Expand All @@ -11,10 +24,32 @@ remove_expired_container_locks

if [ -z "$1" -o "$1" = "--help" ]
then
echo "Syntax: i3-persist [lock|unlock|toggle|kill] [id]"
print_help
exit 0
fi

if [ -z "$1" -o "$1" = "--version" ]
then
print_version
exit 0
fi

while getopts "vh" opt
do
case "$opt" in
v) print_version
exit 0
;;
h) print_help
exit 0
;;
*) print_invalid
exit 1
;;
esac
done


CONTAINER=`argument_or_focused_container "$2"`

if [ "$1" = "lock" ]
Expand Down Expand Up @@ -46,5 +81,5 @@ then
exit 0
fi

printf "i3-persist: invalid operand\nTry 'i3-persist --help' for more information.\n"
print_invalid
exit 1
46 changes: 0 additions & 46 deletions doc/README.md

This file was deleted.

56 changes: 56 additions & 0 deletions doc/man1/i3-persist.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.TH i3-persist 1 "MARCH 2018" 1.0.3 "User Manuals"

.SH NAME
i3-persist \- extends i3 window management with persistent containers



.SH SYNOPSIS
.SY i3-persist
.OP \-v|--version
.OP \-h|--help
.B lock|unlock|toggle|kill
\fIid\fP
.YS

.SH DESCRIPTION
.B i3-persist
closes a container or switches its state from closable to persistent.

Using the featured set of commands, containers can be marked so as to prevent their careless closing. A custom kill command is made available as a plug-in substitute for
.B i3-msg kill.
If a container is marked as persistent, attempted closing of the container through the command will have no effect.

.SH SUBCOMMANDS

.TP
.B lock
Mark the container as persistent. Prevents subsequent closes.
.TP

.B unlock
Mark the container as closable. Allows the container to be closed.

.TP
.B toggle
Toggle the container between the two states.

.TP
.B kill
Close the container unless either the container or any of its descending containers are locked. Otherwise, don't do anything.

.RE
By default,
.B i3-persist
will operate on the currently focused container. For scripting purposes, it is possible to pass a
.B con\_id
to all methods.


.SH AUTHOR
.MT igorsowinski@gmail@\:gmail.com
Igor Sowinski
.ME

.SH COPYRIGHT
Copyright \[u00A9] 2018 Igor Sowinski. Licensed under the 3-clause BSD license.
10 changes: 8 additions & 2 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

if ! command -v shunit2
then
echo -e "${RED}Please install shunit2 first.$NC"
exit 1
fi

echo > tests.log

for FILE in tests/*
Expand All @@ -14,12 +20,12 @@ done

if ! grep -q "ASSERT:" tests.log
then
echo "${GREEN}All tests passed!$NC"
echo -e "${GREEN}All tests passed!$NC"
exit 0
fi

echo "--------------------------------------------\n"
echo "$RED$(grep -c "ASSERT:" tests.log) tests failed!$NC"
echo -e "$RED$(grep -c "ASSERT:" tests.log) tests failed!$NC"
echo "Failed tests:"
grep -B1 "ASSERT:" tests.log | grep -v "ASSERT:" | sed 's/^/- /'

Expand Down

0 comments on commit e501b7c

Please sign in to comment.