Skip to content

Commit

Permalink
misc: Update submodule
Browse files Browse the repository at this point in the history
Module name has changed for libshlist.
Update the lib with some fixes for exit codes
and function documentation

Signed-off-by: Thomas Venriès <thomas.venries@gmail.com>
  • Loading branch information
Thomas Venriès committed Nov 5, 2017
1 parent 3c7f0fe commit 8dc0f24
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*

!posix-shell-list
!libshlist

!img
img/*
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "posix-shell-list"]
path = posix-shell-list
url = https://github.com/Ventto/posix-shell-list.git
[submodule "libshlist"]
path = libshlist
url = https://github.com/Ventto/libshlist.git
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PKGDESC = POSIX Shell script to quickly manage 2-monitors display.
LICENSEDIR = $(DESTDIR)/usr/share/licenses/$(PKGNAME)
MANDIR = $(DESTDIR)/usr/share/man/man1
BINDIR = $(DESTDIR)/usr/bin
LIBDIR = $(DESTDIR)/usr/lib/posix-shell-list
LIB = posix-shell-list/list.sh
LIBDIR = $(DESTDIR)/usr/lib/libshlist
LIB = libshlist/liblist.sh

install:
@if ! [ -r "$(LIB)" ]; then \
Expand All @@ -25,7 +25,7 @@ install:
chmod 644 $(LIB)
chmod 755 mons
cp LICENSE $(LICENSEDIR)/LICENSE
cp $(LIB) $(LIBDIR)/list.sh
cp $(LIB) $(LIBDIR)/liblist.sh
cp mons $(BINDIR)/mons

uninstall:
Expand Down
1 change: 1 addition & 0 deletions libshlist
Submodule libshlist added at 1cbcdc
50 changes: 25 additions & 25 deletions mons
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if [ ! -f "/usr/lib/posix-shell-list/list.sh" ]; then
echo '/usr/lib/posix-shell-list/list.sh: library not found.'
if [ ! -f "/usr/lib/libshlist/liblist.sh" ]; then
echo '/usr/lib/libshlist/liblist.sh: library not found.'
exit 1
fi

. /usr/lib/posix-shell-list/list.sh
. /usr/lib/libshlist/liblist.sh

usage() {
echo 'Usage: mons [OPTION]...
Expand Down Expand Up @@ -104,14 +104,14 @@ arg2xrandr() {
}

whichmode() {
if [ "$(list_len "${disp_mons}")" -eq 1 ]; then
if [ "$(list_size "${disp_mons}")" -eq 1 ]; then
if echo "${enabled_out}" | grep prima > /dev/null 2>&1; then
echo 'primary'
else
echo 'second'
fi
else
if [ "$(list_len "${plug_mons}")" -gt 2 ] ; then
if [ "$(list_size "${plug_mons}")" -gt 2 ] ; then
echo 'selection'; return 0
fi

Expand Down Expand Up @@ -275,15 +275,15 @@ main() {
# connected monitor that appears in the xrandr output is considerate as
# the primary one.
if [ -n "${primary}" ]; then
plug_mons="$(list_del "${primary}" "${plug_mons}")"
plug_mons="$(list_erase "${primary}" "${plug_mons}")"
plug_mons="$(list_insert "${primary}" 0 "${plug_mons}")"
fi

enabled_out="$(echo "${enabled_out}" | grep -E '\+[0-9]{1,4}\+[0-9]{1,4}')"
disp_mons="$(echo "${enabled_out}" | cut -d' ' -f1)"

if [ "$#" -eq 0 ]; then
echo "Monitors: $(list_len "${plug_mons}")"
echo "Monitors: $(list_size "${plug_mons}")"
echo "Mode: $(whichmode)"

i=0
Expand Down Expand Up @@ -314,7 +314,7 @@ main() {
esac
fi

if [ "$(list_len "${plug_mons}")" -eq 1 ] ; then
if [ "$(list_size "${plug_mons}")" -eq 1 ] ; then
if $oFlag ; then
# After unplugging each monitor, the last preferred one might be
# still turned off or the window manager might need the monitor
Expand All @@ -327,19 +327,19 @@ main() {
fi

if $oFlag ; then
if [ "$(list_len "${disp_mons}")" -eq 1 ]; then
if [ "$(list_head "${disp_mons}")" = "$(list_head "${plug_mons}")" ]; then
if [ "$(list_size "${disp_mons}")" -eq 1 ]; then
if [ "$(list_front "${disp_mons}")" = "$(list_front "${plug_mons}")" ]; then
exit
fi
fi
disp_mons="$(list_del "$(list_head "${plug_mons}")" "$disp_mons")"
disp_mons="$(list_erase "$(list_front "${plug_mons}")" "$disp_mons")"
disable_mons "${disp_mons}"
enable_mon "$(list_head "${plug_mons}")"
enable_mon "$(list_front "${plug_mons}")"
exit
fi

if $OFlag ; then
if [ "${OArg}" -ge "$(list_len "${mons}")" ] ; then
if [ "${OArg}" -ge "$(list_size "${mons}")" ] ; then
echo "Monitor ID '${OArg}' does not exist."
echo 'Try without option to get monitor ID list.'
exit 2
Expand All @@ -351,15 +351,15 @@ main() {
exit 2
fi

disp_mons="$(list_del "${mons_elt}" "${disp_mons}")"
disp_mons="$(list_erase "${mons_elt}" "${disp_mons}")"
disable_mons "${disp_mons}"
enable_mon "${mons_elt}"
exit
fi

if $SFlag ; then
if [ "${idx1}" -ge "$(list_len "${mons}")" ] || \
[ "${idx2}" -ge "$(list_len "${mons}")" ]; then
if [ "${idx1}" -ge "$(list_size "${mons}")" ] || \
[ "${idx2}" -ge "$(list_size "${mons}")" ]; then
echo 'One or both monitor IDs do not exist.'
echo 'Try without option to get monitor ID list.'
exit 2
Expand All @@ -375,25 +375,25 @@ main() {

mon1="$(list_get "${idx1}" "${mons}")"
mon2="$(list_get "${idx2}" "${mons}")"
disp_mons="$(list_del "${mon1}" "${disp_mons}")"
disp_mons="$(list_del "${mon2}" "${disp_mons}")"
disp_mons="$(list_erase "${mon1}" "${disp_mons}")"
disp_mons="$(list_erase "${mon2}" "${disp_mons}")"
disable_mons "${disp_mons}"
enable_mon "${mon1}"
enable_mon "${mon2}"
"${XRANDR}" --output "${mon2}" "${area}" "${mon1}"
exit
fi

if [ "$(list_len "${plug_mons}")" -eq 2 ]; then
if [ "$(list_size "${plug_mons}")" -eq 2 ]; then
if $sFlag ; then
if [ "$(list_len "${disp_mons}")" -eq 1 ] ; then
if [ "$(list_head "${disp_mons}")" = "$(list_get 1 "${plug_mons}")" ] ; then
if [ "$(list_size "${disp_mons}")" -eq 1 ] ; then
if [ "$(list_front "${disp_mons}")" = "$(list_get 1 "${plug_mons}")" ] ; then
enable_mon "$(list_get 1 "${plug_mons}")"
exit
fi
fi
enable_mon "$(list_get 1 "${plug_mons}")"
disable_mons "$(list_head "${disp_mons}")"
disable_mons "$(list_front "${disp_mons}")"
exit
fi

Expand All @@ -403,7 +403,7 @@ main() {

if $dFlag ; then
"${XRANDR}" --output "$(list_get 1 "${plug_mons}")" \
--same-as "$(list_head "${plug_mons}")"
--same-as "$(list_front "${plug_mons}")"
exit $?
fi

Expand All @@ -420,13 +420,13 @@ main() {

"${XRANDR}" --output "$(list_get 1 "${plug_mons}")" \
--auto --scale-from "${size}" \
--output "$(list_head "${plug_mons}")"
--output "$(list_front "${plug_mons}")"
exit $?
fi

if $eFlag ; then
"${XRANDR}" --output "$(list_get 1 "${plug_mons}")" \
"$(arg2xrandr "$eArg")" "$(list_head "${plug_mons}")"
"$(arg2xrandr "$eArg")" "$(list_front "${plug_mons}")"
exit $?
fi
else
Expand Down
1 change: 0 additions & 1 deletion posix-shell-list
Submodule posix-shell-list deleted from 5b490c

0 comments on commit 8dc0f24

Please sign in to comment.