From 0996b13bda55dd52a98c7296946dca494943e441 Mon Sep 17 00:00:00 2001 From: Uwe Werler Date: Fri, 28 Aug 2020 19:40:42 +0000 Subject: [PATCH] init --- brightness.sh | 42 ++++++++++++++++++ vimb-session.sh | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100755 brightness.sh create mode 100755 vimb-session.sh diff --git a/brightness.sh b/brightness.sh new file mode 100755 index 0000000..490861f --- /dev/null +++ b/brightness.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright (c) 2020 Uwe Werler +# +# 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 diff --git a/vimb-session.sh b/vimb-session.sh new file mode 100755 index 0000000..85b87ec --- /dev/null +++ b/vimb-session.sh @@ -0,0 +1,116 @@ +#!/bin/ksh +# +# Copyright (c) 2020 Uwe Werler +# +# 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 ... ] + -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