Merge branch 'master' of git.schuerz.at:public/myshellconfig

This commit is contained in:
Jakobus Schürz 2020-11-15 22:20:05 +01:00
commit 4164907f03
13 changed files with 312 additions and 35 deletions

View file

@ -56,7 +56,7 @@ if [[ $- = *i* ]] ; then
[ -z "${MYSHELLCONFIG_LOGDIR+x}" ] && export MYSHELLCONFIG_LOGDIR="${HOME}/logs"
[ -z "${MYSHELLCONFIG_LOGFILE+x}" ] && export MYSHELLCONFIG_LOGFILE="${MYSHELLCONFIG_LOGDIR}/myshellconfig.log"
[ -z "${MYHSELLCONFIG_LOGLEVEL_DEFAULT+x}" ] && export MYHSELLCONFIG_LOGLEVEL_DEFAULT="INFO"
[ -z "${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT+x}" ] && export MYHSELLCONFIG_FILELOGLEVEL_DEFAULT="INFO"
[ -z "${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT+x}" ] && export MYHSELLCONFIG_FILELOGLEVEL_DEFAULT="DEBUG"
[ -z "${SCRIPT_LOG+x}" ] && export SCRIPT_LOG="${MYSHELLCONFIG_LOGFILE}"
[ -z "${LOGLEVEL_DEFAULT+x}" ] && export LOGLEVEL_DEFAULT="${MYHSELLCONFIG_LOGLEVEL_DEFAULT-INFO}"
[ -z "${FILELOGLEVEL_DEFAULT+x}" ] && export FILELOGLEVEL_DEFAULT="${MYHSELLCONFIG_FILELOGLEVEL_DEFAULT-INFO}"
@ -99,7 +99,7 @@ EOF
local nok=""
local gco=""
if which git >/dev/null; then
echo -n "Sync config with ${MYSHELLCONFIG_GIT_SERVER}: " 1>&2
loginfo -n "Sync config with ${MYSHELLCONFIG_GIT_SERVER}: "
# MYSHELLCONFIG_GITCHECKOUTSCRIPT_OPTIONS are options for bin/git-myshellconfig-checkout
if [ -z ${MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS+x} ]; then
gco="-h"
@ -107,7 +107,7 @@ EOF
gco="$MYSHELLCONFIG_GIT_CHECKOUTSCRIPT_OPTIONS"
fi
${MYSHELLCONFIG_BASE}/bin/git-myshellconfig-checkout ${gco}|| nok="not " 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1
printf '%s\n' "${nok}synced" 1>&2
loginfo "$(printf '%s\n' "${nok}synced" )"
[ -z "$nok" ] && mkdir -pv "${MYSHELLCONFIG_LOGDIR}"
else

194
bin/exif-fixdatetime Executable file
View file

@ -0,0 +1,194 @@
#!/bin/bash
export SCRIPT_LOG=./$(basename $0).log
[ -z "${move+x}" ] && move=false
[ -z "${forcedate+x}" ] && forcedate=false
[ -z "${setdate+x}" ] && setdate=true
# Pathdefinitions Default
[ -z "${dest+x}" ] && dest=/srv/nfs/data/userdata/SHARED && dest=${dest%/}
[ -z "${mimedestpicdefault+x}" ] && mimedestpicdefault="Bilder"
[ -z "${mimedestviddefault+x}" ] && mimedestviddefault="Videos"
[ -z "${subdestdefault+x}" ] && subdestdefault="Familie"
# Pathdefinitions Runtime
[ -z "${mimedestpic+x}" ] && mimedestpic="${mimedestpicdefault}"
[ -z "${mimedestvid+x}" ] && mimedestvid="${mimedestviddefault}"
[ -z "${subdestpic+x}" ] && subdestpic="${subdestdefault}"
[ -z "${subdestvid+x}" ] && subdestvid="${subdestdefault}"
help () {
cat << EOF
Usage: $(basename $0) [move=[true|copy]] [setdate=[true|false]] [forcedate=[true|false]] [<file>]
Defaults:
# commands
move=$move [false|true|copy] false: file is not moved to destination; true: file is moved; copy: copy file to destination
forcedate=$forcedate [fase|true] false: datetimeoriginal and createdate is only updated from filename, if not set; true: tags are always updated
setdate=$setdate [false|true] false: do not set date-tags, only if you are sure, tags are ok, and you want move or copy files;
# destination
dest=$dest
mimedestpic=$mimedestpic
mimedestvid=$mimedestvid
subdestpic=$subdestpic
subdestvid=$subdestvid
# final destinationpath
${dest}/${mimedestpic}/${subdestpic}/%Y/%Y_%m"
${dest}/${mimedestvid}/${subdestvid}/%Y/%Y_%m"
Supported Filet-extensions
*.jpg, *.jpeg, *.png, *.mp4
Examples:
# Scan current directory for all jpg|jpeg|mp4|png files, set datetimeoriginal and createdate
$(basename $0)
# set datetimeoriginal and createdate from given file (only one is possible)
# only if tags are not set
$(basename $0) <filename>
# set datetimeoriginal and createdate from given file (only one is possible)
# overwrite existing tags
forcedate=true $(basename $0) <filename>
# set datetimeoriginal and createdate from given file (only one is possible)
# overwrite existing tags
# move file to destination dir (${dest}/${mimedestpicdefault}/${subdestpic} or ${dest}/${mimedestviddefault}/${subdestvid}) in subdirectories %Y/%Y_%m/.
move=true forcedate=true $(basename $0) <filename>
EOF
}
export FILELOGLEVEL=WARN
export SCRIPT_LOG=~/logs/exif.log
parsedatetime() {
filename="$(basename "${@}")"
# 2015-09-11_17:41:53-1.jpg
if [[ $filename =~ ^.*([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})( |_)([0-9]{2})(\.|-|:)([0-9]{2})(\.|-|:)([0-9]{2})(\.|-).*$ ]]; then
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[7]#0}" "${BASH_REMATCH[9]#0}" "${BASH_REMATCH[11]#0}")"
fi
if [ -z "${result}" ]; then
if [[ $filename =~ ^.*([0-9]{4})([0-9]{2})([0-9]{2})(_|-)([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
fi
fi
if [ -z "${result}" ]; then
# Whatsapp-Bilder
# Whatsapp-Videos
if [[ $filename =~ ^(IMG-|VID-)([0-9]{4})([0-9]{2})([0-9]{2})(-WA)([0-9]{2})([0-9]{2}).*$ ]]; then
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}" "00")"
fi
fi
if [ -z "${result}" ]; then
# eYe20130323123316.jpg
if [[ $filename =~ ^(eYe)([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
fi
fi
if [ -z "${result}" ]; then
# ./2016-01-22/IMG_4225.jpg
echo "FILENAME: $@" >&2
if [[ "$(dirname ${@})" =~ ^.*/([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2}).*$ ]]; then
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "00" "00" "00")"
fi
fi
echo "$result"
return 0
}
fix_datetime () {
file="${@}"
if $forcedate; then
exiftool "-DateTimeOriginal=$newDateTimeOriginal" "$file"
exiftool '-createdate<datetimeoriginal' -if '($datetimeoriginal)' "$file"
else
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
fi
}
run_fix () {
file="${@}"
mime="$(file --mime-type "$file" | awk '{print $NF}')"
loginfo "file: $file : mime-type: $mime"
newDateTimeOriginal="$(parsedatetime "$file")"
loginfo "newDateTimeOriginal: $newDateTimeOriginal"
case $mime in
image/png)
MIMEDEST="${mimedestpic}/${subdestpic}"
;;
image/jpeg)
MIMEDEST="${mimedestpic}/${subdestpic}"
;;
video/mp4|video/m4a)
MIMEDEST="${mimedestvid}/${subdestvid}"
;;
*)
logwarn "unsupportet mimetype »${mime}« for »${file}«"
;;
esac
if [ -n "${MIMEDEST+x}" ] ; then
if [ -n "$newDateTimeOriginal" ]; then
$setdate && fix_datetime "$file"
fi
loginfo "$(exiftool -filename -createdate -datetimeoriginal "$file")"
case $move in
true)
echo move to ${dest}/${MIMEDEST}/%Y/%Y_%m
loginfo "$(exiftool '-Directory<DateTimeOriginal' -d ${dest}/${MIMEDEST}/%Y/%Y_%m -if '($datetimeoriginal)' "$file" 2>&1 |tee -a dest_exists)"
;;
copy)
echo copy to ${dest}/${MIMEDEST}/%Y/%Y_%m
loginfo "$(exiftool -o . '-Directory<DateTimeOriginal' -d ${dest}/${MIMEDEST}/%Y/%Y_%m -filename -createdate -datetimeoriginal -if '($datetimeoriginal)' "$file")"
logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")"
;;
*)
logwarn "value for move is neither »true« nor »copy«"
esac
fi
loginfo "----------------"
loginfo ""
}
if [ $# -gt 0 ]; then
case $1 in
-h|help|--help)
help
;;
*)
loginfo "Progress only one file from cmdline ${@}"
run_fix "${@}"
;;
esac
else
loginfo "Progress all *.jpg, *.jpeg, *.png and mp4 files in pwd $(pwd)"
all=$(find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$"|wc -l)
find ${maxdepth:+-maxdepth} ${maxdepth:+$maxdepth} -type f |grep -i ".jpg$\|.jpeg$\|.mp4$\|.png$"|while read file; do
let "i=i+1"
loginfo "$i/$all"
run_fix "$file"
done
fi

View file

@ -33,18 +33,25 @@ cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
+-----BEGINN git update repo $(date) -------------------------------+
EOF
case $1 in
-h)
# Headless repo local
PRE="${MYSHELLCONFIG_GIT_REMOTE_NAME}"
;;
-s)
dosubmodupdate="true"
;;
*)
PRE=""
;;
esac
set -- $(getopt -u -o hs --long headless,submodules-update -- "$@" )
while [ $# -gt 0 ]; do
case $1 in
-h|--headless)
# Headless repo local
PRE="${MYSHELLCONFIG_GIT_REMOTE_NAME}"
shift
;;
-s|--submodules-update)
dosubmodupdate="true"
shift
;;
*)
PRE=""
shift
;;
esac
done
# If TAG is set, checkout is always headless.
[ -z "${MYSHELLCONFIG_GIT_TAG:+x}" ] || { export MYSHELLCONFIG_GIT_BRANCH=${MYSHELLCONFIG_GIT_TAG}; export PRE=""; }
@ -53,11 +60,14 @@ esac
# Check for updates in submodules only if last check was INTERVALL hours in the past
updated=$(cat ${MYSHELLCONFIG_BASE%/}${MYSHELLCONFIG_BASE:+/}.last_update_submodules 2>/dev/null || echo 0 )
if [ $updated -lt $(date --date="${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_INTERVALL} hours ago" "+%s") ]; then
dosubmodupdate="true"
logtrace "dosubmodupdate before: $dosubmodupdate"
if [ $updated -lt $(date --date="${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_INTERVALL} hours ago" "+%s") -a ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then
[ -z "${dosubmodupdate+x}" ] && dosubmodupdate="true"
fi
logtrace "dosubmodupdate after: $dosubmodupdate"
#echo $SGIT fetch ${MYSHELLCONFIG_GIT_REMOTE_NAME} -p 1>&2
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MYSHELLCONFIG_GIT_REMOTE_NAME} -p 2>>"${MYSHELLCONFIG_LOGFILE}"|| { logwarn fetch failed; gitupdateend; exit 1; }
if ${dosubmodupdate:-false}; then
date "+%s" > ${MYSHELLCONFIG_BASE%/}${MYSHELLCONFIG_BASE:+/}.last_update_submodules
@ -95,21 +105,20 @@ EOF
fi
logwarn "
repo synced"
loginfo "repo${dosubmodupdate:+ and submodules} synced"
if ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}; then
#if ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}; then
if ${dosubmodupdate:-false}; then
loginfo "update and commit submodules"
logdebug "$($SGIT submodule update --remote)"
logdebug "$($SGIT commit -a -m 'update submodules')"
date "+%s" > ${MYSHELLCONFIG_BASE%/}${MYSHELLCONFIG_BASE:+/}.last_update_submodules
logwarn "
submodules synced"
logwarn "submodules synced"
fi
else
loginfo -n ", submodules not synced"
logdebug "Do not update submodules. It's denied by environment MYSHELLCONFIG_GIT_UPDATE_SUBMODULES: ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}"
fi
#else
# loginfo -n ", submodules not synced"
# logdebug "Do not update submodules. It's denied by environment MYSHELLCONFIG_GIT_UPDATE_SUBMODULES: ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}"
#fi
EXIT
exit $rc

View file

@ -52,7 +52,7 @@ do
if stat "${file}" >/dev/null 2>/dev/null ; then
echo "Stop $app on ${DEST}"
ssh ${DEST} systemctl stop ${app}.service
cat ${file}|sort -r |while read cmd pkg version ; do
cat ${file}|sort -r |grep -v " *#"|while read cmd pkg version ; do
case $cmd in
install)
if [ -z "${version}" ]; then

View file

@ -283,8 +283,8 @@ agent-load-identity-keys () {
fi
done
fi
logdebug "currently loaded keys after action:
$(ssh-runinagent $agentfile ssh-add -l)"
loginfo "currently loaded keys after action: $(ssh-runinagent $agentfile ssh-add -l|wc -l)"
logdebug "$(ssh-runinagent $agentfile ssh-add -l)"
else
logwarn "ssh-identity $ssh_identity is not configured. Please create $identitydir and add keys"
fi

@ -1 +1 @@
Subproject commit 3866ae170a342fb40d83e1538c37c81c7977b821
Subproject commit 971c4d41880b72dbbf1620b3ad91418a6a6f6b9c

@ -1 +1 @@
Subproject commit d099941360e061587bf7d42cd029c91650ef5a44
Subproject commit 7bd99a22eeba74c88ad60f860111247a052f5586

@ -1 +1 @@
Subproject commit 61c4b6d1ed30287edcbfd3dbaed4e43b5c251c93
Subproject commit 53b3aea0da5e3581e224c958dbc13558cbe5daee

@ -1 +1 @@
Subproject commit 01b84c63b9ba48628285779fbdfd046dd2bc2970
Subproject commit 9e33a3fe8aa90f5ece2439f3b1b3a98fe7e35f85

@ -1 +1 @@
Subproject commit 5f2421fa3952311df652d9e2994774e6b0d9c7cd
Subproject commit 536667191d5bdc0afa3a18d7df229731e778815e

@ -1 +1 @@
Subproject commit 3dafdfc0424716bae21f5340314f7d90a9ddf4f2
Subproject commit cd6f16978d5af4b9fb861be9d728732d72789df3

View file

@ -0,0 +1,19 @@
## Toggle Background Function
Solarized comes with a Toggle Background plugin that by default will map to if that mapping is available. If it is not available you will need to either map the function manually or change your current mapping to something else.
To set your own mapping in your .vimrc file, simply add the following line to support normal, insert and visual mode usage, changing the "" value to the key or key combination you wish to use:
```
call togglebg#map("<F5>")
```
Note that you'll want to use a single function key or equivalent if you want the plugin to work in all modes (normal, insert, visual).
## Note
This script has been developed by Ethan Schoonover for his Solarized color scheme.
Original work can be found here: [Original Script]
[Original Script]:https://github.com/altercation/vim-colors-solarized

View file

@ -0,0 +1,55 @@
" Toggle Background
" Modified: 2011 Apr 29
" Maintainer: Ethan Schoonover
" License: OSI approved MIT license
if exists("g:loaded_togglebg")
finish
endif
let g:loaded_togglebg = 1
" noremap is a bit misleading here if you are unused to vim mapping.
" in fact, there is remapping, but only of script locally defined remaps, in
" this case <SID>TogBG. The <script> argument modifies the noremap scope in
" this regard (and the noremenu below).
nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG
inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a
vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv
nnoremenu <script> Window.Toggle\ Background <SID>TogBG
inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a
vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv
tmenu Window.Toggle\ Background Toggle light and dark background modes
nnoremenu <script> ToolBar.togglebg <SID>TogBG
inoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>a
vnoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>gv
tmenu ToolBar.togglebg Toggle light and dark background modes
noremap <SID>TogBG :call <SID>TogBG()<CR>
function! s:TogBG()
let &background = ( &background == "dark"? "light" : "dark" )
if exists("g:colors_name")
exe "colorscheme " . g:colors_name
endif
endfunction
if !exists(":ToggleBG")
command ToggleBG :call s:TogBG()
endif
function! ToggleBackground()
echo "Please update your ToggleBackground mapping. ':help togglebg' for information."
endfunction
function! togglebg#map(mapActivation)
try
exe "silent! nmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
exe "silent! imap <unique> ".a:mapActivation." <Plug>ToggleBackground"
exe "silent! vmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
finally
return 0
endtry
endfunction
if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
call togglebg#map("<F5>")
endif