This commit is contained in:
ilya 2025-06-06 00:14:54 +02:00
parent 73fa6cf1b6
commit ffd27dd111
8 changed files with 129 additions and 57 deletions

View File

@ -57,18 +57,30 @@ function contact_split {
local card_guid local card_guid
declare -a card_lines declare -a card_lines
uid_found=false
while read line; do while read line; do
if [[ "$line" =~ ^END:VCARD ]]; then
if ! $uid_found ; then
card_lines=("${card_lines[@]}" "UID:$(uid)")
fi
fi
# Append each line to the end of this array. # Append each line to the end of this array.
card_lines=("${card_lines[@]}" "$line") card_lines=("${card_lines[@]}" "$line")
# Get the contact's GUID, this becomes the file name. # Get the contact's GUID, this becomes the file name.
if [[ "$line" =~ ^N: ]]; then if [[ "$line" =~ ^FN: ]]; then
card_guid=$(echo -n "$line" | cut -d ':' -f 2) card_guid=$(echo -n "$line" | cut -d ':' -f 2)
fi fi
# Remember if we found an uid
if [[ "$line" =~ ^UID: ]]; then
uid_found=true
fi
# This is the end of the card, so output it. # This is the end of the card, so output it.
if [[ "$line" =~ ^END:VCARD ]]; then if [[ "$line" =~ ^END:VCARD ]]; then
printf "%s\n" "${card_lines[@]}" > "$dest/$(echo -n "$card_guid" | sed 's/;/_/g' | tr 'A-Z' 'a-z' | tr -d '\r').vcf" uid_found=false
printf "%s\n" "${card_lines[@]}" > "$dest/$(echo -n "$card_guid" | sed 's/;/_/g' | tr 'A-Z' 'a-z' | tr -d '\r ').vcf"
unset -v card_lines unset -v card_lines
fi fi
done done
@ -419,15 +431,17 @@ IFS=$ORIG_IFS
} }
##### Main ##### # MAIN FUNCTION
phone_to_vcf () {
# Copy contacts from phone via adb and convert them to vcf
tmp="$(mktemp -d)"
tmp="$(mktemp -d)" echo "Get db from phone"
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db "$tmp"
echo "Get db from phone" echo "Convert it to multiple vcard files"
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db "$tmp" dump-contacts2db "$tmp/contacts2.db" | contact_split "${1:-$HOME/.contacts/vcards}"
echo "Convert it to multiple vcard files" echo "Clean"
dump-contacts2db "$tmp/contacts2.db" | contact_split "${1:-$HOME/.contacts/vcards}" rm -r "$tmp"
}
echo "Clean"
rm -r "$tmp"

View File

@ -5,21 +5,34 @@ tmp="$(mktemp)"
final="$(mktemp)" final="$(mktemp)"
sed \ sed \
-e 's/adj/\n**Aujourdhui**\n/' \ -e 's/ / /g' \
-e 's/^hier/\n**Hier**\n/' \ -e 's/^adj */\n\n**Cet après-midi**/' \
-e 's/^diffic.*/\n**Difficultés**\n/i' \ -e 's/^aprem */\n\n**Cet après-midi**/' \
-e 's/^matin */\n\n**Ce matin**/' \
-e 's/^hier */\n\n**Hier après-midi**/' \
-e 's/\( \|^\)maj\( \|$\)/mise à jour/' \
-e 's/^diffic.*/\n\n**Difficultés**\n/i' \
-e 's/^ *information.*/# Points divers/i' \ -e 's/^ *information.*/# Points divers/i' \
-e 's/^point.* diver.*/# Points divers/i' \ -e 's/^point.* diver.*/# Points divers/i' \
-e 's/^\([^-*#@:][^*#@:]\+\) \+:/- \U\1 :/' \ -e 's/^point.* g.n.raux.*/# Points divers/i' \
-e 's/^info.* g.n.ra.*/# Points divers/i' \
-e 's/^difficult.s.*/# Difficultés/i' \
-e 's/^message.* g.n.raux.*/# Points divers/i' \
-e 's/^tickets$/dbm : tickets/g' \
-e 's/^\([^-*#: ]\+\)$/# @\U\1/' \
-e 's/^\([^-*#@: ][^*#@:]\+[^: ]\) *: */- \U\1 : /' \
-e 's/^\([^-*#@:]\+\)$/- \1/' \
-e 's/ \+/ /g' \
-e 's/dde/demande/g' \
-e 's/pb/problème/g' \
"$f" > "$tmp" "$f" > "$tmp"
#sed -i -e 's/^\([^-*#\s ]\)/# @\U\1/' "$tmp"
sed -i -e 's/^\([^-*#\s]\)/# @\U\1/' "$tmp"
echo " echo "
**Daily Stand-Up Meeting du $(date '+%d %h %Y')** **Daily Stand-Up Meeting du $(date '+%d %h %Y')**
- Où : BBB/standup - Où : https://bbb.dbm.tech/rooms/05n-3ax-qwg-9n8/join
- Participants : $(grep -o '@.*' "$tmp" | tr '\n' ',' | sed 's/,$/\n/') - Participants : $(grep -o '@.*' "$tmp" | tr '\n' ',' | sed 's/,$/\n/')
- Quand : $(date '+%Y/%m/%d') 9:45 - Quand : $(date '+%Y/%m/%d') 12h05
- Durée : 00:15 '(+0mn) - Durée : 00:15 '(+0mn)
- Scribe : Adrian - Scribe : Adrian
- Relecteur : - Relecteur :

13
gw.sh
View File

@ -10,27 +10,28 @@ root_or_die
local_iface="$1" local_iface="$1"
net_iface="$2" net_iface="$2"
net="192.168.99"
run sysctl net.ipv4.ip_forward=1 run sysctl net.ipv4.ip_forward=1
clean "sysctl net.ipv4.ip_forward=1" #clean "sysctl net.ipv4.ip_forward=1"
run nmcli device set "$local_iface" managed no run nmcli device set "$local_iface" managed no
clean "nmcli device set "$local_iface" managed yes" clean "nmcli device set "$local_iface" managed yes"
run ip a add 192.168.238.254/24 dev "$local_iface" run ip a add $net.254/24 dev "$local_iface"
clean "ip a del 192.168.238.254/24 dev $local_iface" clean "ip a del $net.254/24 dev $local_iface"
# For dhcp offers # For dhcp offers
run iptables -A OUTPUT -d 255.255.255.255/32 -j ACCEPT run iptables -A OUTPUT -d 255.255.255.255/32 -j ACCEPT
run iptables -A OUTPUT -d 192.168.238.0/24 -j ACCEPT run iptables -A OUTPUT -d $net.0/24 -j ACCEPT
run iptables -A INPUT -s 192.168.238.0/24 -j ACCEPT run iptables -A INPUT -s $net.0/24 -j ACCEPT
run iptables -A INPUT -s 255.255.255.255 -j ACCEPT run iptables -A INPUT -s 255.255.255.255 -j ACCEPT
run iptables -A INPUT -i "$local_iface" -j ACCEPT run iptables -A INPUT -i "$local_iface" -j ACCEPT
run iptables -t nat -A POSTROUTING -o "$net_iface" -j MASQUERADE run iptables -t nat -A POSTROUTING -o "$net_iface" -j MASQUERADE
run iptables -A FORWARD -i $net_iface -o $local_iface -m state --state RELATED,ESTABLISHED -j ACCEPT run iptables -A FORWARD -i $net_iface -o $local_iface -m state --state RELATED,ESTABLISHED -j ACCEPT
run iptables -A FORWARD -i $local_iface -o $net_iface -j ACCEPT run iptables -A FORWARD -i $local_iface -o $net_iface -j ACCEPT
run dnsmasq --dhcp-range=192.168.238.100,192.168.238.199,10m -d --server=9.9.9.9 --listen-address 192.168.238.254 --interface "$local_iface" -p0 run dnsmasq --dhcp-range=$net.100,$net.199,10m -d --server=9.9.9.9 --listen-address $net.254 --interface "$local_iface" -p0
clean clean

View File

@ -3,26 +3,40 @@
set -euo pipefail set -euo pipefail
echo "vars" echo "vars"
htpasswd="$(mktemp)" user="emails"
venv=~/.cache/radicale-venv venv="/home/$user/.cache/radicale-venv"
htpasswd="$venv/htpasswd"
#locale_ip_addr="$(ip -o -4 a show dev usb0 | grep -Po 'inet[[:space:]]+\K192.168.42.[0-9]{1,3}')" #locale_ip_addr="$(ip -o -4 a show dev usb0 | grep -Po 'inet[[:space:]]+\K192.168.42.[0-9]{1,3}')"
locale_ip_addr="192.168.42.58" locale_ip_addr="192.168.42.205"
port=5232 port=5232
echo ip
sudo ip a add "$locale_ip_addr/32" dev usb0 || true
sudo -u "$user" bash <<EOF
set -euo pipefail
echo "Creating venv"
if [ ! -d "$venv" ] || [ -z "$(ls -A "$venv")" ] ; then if [ ! -d "$venv" ] || [ -z "$(ls -A "$venv")" ] ; then
virtualvenv "$venv" python -m venv "$venv"
. "$venv/bin/activate"
pip3 install radicale
fi fi
sudo ip a add "$locale_ip_addr" dev usb0
echo "populating htpasswd. Enter password :" echo "populating htpasswd. Enter password :"
htpasswd -c "$htpasswd" dav if [ ! -s "$htpasswd" ] ; then
htpasswd -c "$htpasswd" dav
fi
echo "venv" echo "activating venv"
. venv/bin/activate . "$venv/bin/activate"
echo "runing on $locale_ip_addr:$port" echo "runing on $locale_ip_addr:$port"
python3 -m radicale -H "$locale_ip_addr:$port" --storage-filesystem-folder=~/.contacts --auth-type=htpasswd --auth-htpasswd-encryption md5 --auth-htpasswd-filename "$htpasswd" python3 -m radicale -H "$locale_ip_addr:$port" --storage-filesystem-folder=~/.contacts/bdays --auth-type=htpasswd --auth-htpasswd-encryption md5 --auth-htpasswd-filename "$htpasswd"
echo "Cleaning" EOF
rm "$htpasswd"
echo "OK. Terminated."

View File

@ -82,27 +82,26 @@ i=0
xrandr --listactivemonitors | tail -n +2 | cut -d ' ' -f 6 | while read monitor ; do xrandr --listactivemonitors | tail -n +2 | cut -d ' ' -f 6 | while read monitor ; do
args='' args=''
if [ "$i" -eq 0 ] ; then if [ "$i" -eq 0 ] ; then
brightness="$(brigthness_of_display "$monitor")"
read r g b <<< "$(gamma_of_display "$monitor")"
((i=i+1)) ((i=i+1))
case "$property" in case "$property" in
brightness) brightness)
if [ "$action" = '=' ] ; then if [ "$action" = '=' ] ; then
args="--brightness 1" brightness=1
else else
b="$(brigthness_of_display "$monitor")" brightness="$( echo "$brightness $action $BRIGHTNESS_INCREMENT" | bc -l )"
b="$( echo "$b $action $BRIGHTNESS_INCREMENT" | bc -l )"
args="--brightness $b"
fi fi
;; ;;
redness) redness)
if [ "$action" = '=' ] ; then if [ "$action" = '=' ] ; then
args="--gamma 1:1:1" r=1
g=1
b=1
else else
read r g b <<< "$(gamma_of_display "$monitor")" r="$( echo "$r $action $R_INCREMENT" | bc -l )"
g="$( echo "$g $action $G_INCREMENT" | bc -l )"
rnew="$( echo "$r $action $R_INCREMENT" | bc -l )" b="$( echo "$b $action $B_INCREMENT" | bc -l )"
gnew="$( echo "$g $action $G_INCREMENT" | bc -l )"
bnew="$( echo "$b $action $B_INCREMENT" | bc -l )"
args="--gamma $rnew:$gnew:$bnew"
#echo "from $r:$g:$b to $rnew:$gnew:$bnew" #echo "from $r:$g:$b to $rnew:$gnew:$bnew"
fi fi
;; ;;
@ -110,6 +109,9 @@ xrandr --listactivemonitors | tail -n +2 | cut -d ' ' -f 6 | while read monitor
echo "Invalid property $property" echo "Invalid property $property"
exit 1 exit 1
esac esac
# Build command line args from variables
args="--brightness $brightness --gamma $r:$g:$b"
else else
args="--same-as $monitor" args="--same-as $monitor"
fi fi

View File

@ -2,7 +2,25 @@
#feedreader &>/dev/null & #feedreader &>/dev/null &
#jami-gnome &>/dev/null & #jami-gnome &>/dev/null &
nicotine &>/dev/null & #nicotine &>/dev/null &
qbittorrent &>/dev/null & #qbittorrent &>/dev/null &
#vdirsyncer sync #vdirsyncer sync
sudo -u emails syncmails
if [ "$(host -t a wg.rezine.org 9.9.9.9 2>/dev/null | grep -o ' has address .*')" != "$(host -t a wg.rezine.org 2>/dev/null | grep -o ' has address .*')" ] ; then
echo "-------------------------"
echo ""
echo "wg.rezine.org seems to have changed, you mail need to update your /etc/dnsmasq.conf"
notify-send "Consistency check" "wg.rezine.org seems to have changed, you mail need to update your /etc/dnsmasq.conf"
echo ""
echo "-------------------------"
sleep 3
fi
sudo -u emails bash <<EOF
if [ -n "\$(find ~/.mails/collected_addresses.txt -mtime +24)" ] ; then
echo 'Rebuild mail addressbook'
(notmuch address --output sender '*' ; notmuch address --output recipients '*') | grep -vP "<.*[\x00-\x1F\x7F-\xFF].*>" | grep -vP "[\x00-\x1F\x7F-\xFF]\S*@" | grep -vP "@\S*[\x00-\x1F\x7F-\xFF]" | sort -u > ~/.mails/collected_addresses.txt
fi
syncmails
EOF

View File

@ -1,7 +1,17 @@
#!/bin/bash #!/bin/bash
offlineimap set -u
cd ~/offlineimap3
if [ ! -d venv ] ; then
virtualenv venv
fi
. venv/bin/activate
python offlineimap.py
while true ; do while true ; do
sleep 30 sleep 30
offlineimap -q python offlineimap.py -q
done done

2
term
View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
pid="$(xdotool getactivewindow getwindowpid)" pid="$(xdotool getactivewindow getwindowpid)"
[ -n "$pid" ] && cd "$(readlink -f "/proc/$(pgrep -P "$pid")/cwd")" &>/dev/null || cd "$HOME" [ -n "$pid" ] && cd "$(readlink -f "/proc/$(pgrep -P "$pid")/cwd")" &>/dev/null || cd "$HOME"
exec st "${SHELL:-bash}" exec st "${SHELL:-bash}"