This commit is contained in:
Alcali 2020-08-28 19:40:42 +00:00
commit 0996b13bda
2 changed files with 158 additions and 0 deletions

42
brightness.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
#
# Copyright (c) 2020 Uwe Werler <uwe@werler.is>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
# This is a small script to adjust brightness at my Dell Latitude via xrand
# because xbacklight / wsconsctl doesn't work. It's usually invoked my cwm.
# Therefore I have the following bindings configured: #
#
# bind-key 4-F11 '~/bin/brightness.sh -0.1'
# bind-key 4-F12 '~/bin/brightness.sh +0.1'
# bind-key C4-F11 '~/bin/brightness.sh 0.5'
# bind-key C4-F12 '~/bin/brightness.sh 1.0'
xrandr --verbose | { while read _line; do
case $_line in
*\ connected*)
DEV=${_line%% connected*}
;;
Brightness:\ *)
[[ ${1} == "1.0" ]] && { xrandr --output ${DEV} --brightness ${1}; continue; }
[[ ${1} == "0.5" ]] && { xrandr --output ${DEV} --brightness ${1}; continue; }
xrandr --output ${DEV} --brightness $( echo ${_line##Brightness: }${1} | bc)
;;
esac
done
}
#vim: set ai:ts=2:et:sw=2

116
vimb-session.sh Executable file
View File

@ -0,0 +1,116 @@
#!/bin/ksh
#
# Copyright (c) 2020 Uwe Werler <uwe@werler.is>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
# This script opens all bookmarks matching tag(s) in vimb browser. This
# simulates a session-like behaviour I used especially with pinned tabs in
# Iridium. It can start vimb browser also in tabbed. Can be invoked via a key
# binding in cwm.
set -A _ARGS -- "${@}"
_bookmark="${HOME}/.config/vimb/bookmark"
usage(){
print \
"
usage: $0 [ -f file ] [ -t ] <tag> [ tag ... ]
-f: use non default bookmark file
-t: start vimb in tabbed
tag: case insensitive tag to match in bookmarks to open in vimb
"
exit 1
}
_startvimb() {
type vimb >/dev/null || print "Can't find vimb."
if [[ -n ${_tabbed} ]]; then
type tabbed >/dev/null || print "Can't find tabbed."
[[ -z ${_winid} ]] && _winid=$(tabbed -n vimb -c -d 2>/dev/null)
vimb --embed ${_winid} ${1} &
else
vimb ${1} &
fi
}
_readbookmarks() {
typeset -l local _tag
typeset -l local _tags
local URL
{ while read _url _tags; do
for _tag in $@; do
for _t in ${_tags}; do
if [[ ${_t} == ${_tag} ]]; then
_tagmatch=1
# don't start vimb multiple times when more than one tag matches
[[ ${URL} != ${_url} ]] && _startvimb ${_url}
URL=${_url}
fi
done
done
done
} <${_bookmark}
[[ -z ${_tagmatch} ]] && print "No matching tags found."
}
while getopts "f:t" _opt; do
case "${_opt}" in
f)
unset _ARGS[0]
unset _ARGS[1]
_bookmark=${OPTARG}
set -A _ARGS -- ${_ARGS[@]}
;;
t)
unset _ARGS[0]
set -A _ARGS -- ${_ARGS[@]}
_tabbed=1
;;
*)
usage
;;
esac
done
[[ -z ${_ARGS[*]} ]] && print "Missing tag argument." && usage
shift $((OPTIND-1))
[ $# -gt 0 ] || usage
if [[ -r ${_bookmark} ]]; then
_readbookmarks ${_ARGS[@]}
else
print "Cant't read bookmark file."
usage
fi
#vim: set ai:ts=2:et:sw=2