From 536e323a34cc3b939e3c6611fe2f6eaac54b51e5 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 22 Feb 2017 17:57:09 +0100 Subject: [PATCH] add scripts to manage minutes and statistics --- bin/5fire.sh | 85 +++++++++++++++++++++++++++++++++++++ bin/brisk_explain_update.sh | 13 ++++++ bin/brisk_pts_update.sh | 5 +++ 3 files changed, 103 insertions(+) create mode 100755 bin/5fire.sh create mode 100755 bin/brisk_explain_update.sh create mode 100755 bin/brisk_pts_update.sh diff --git a/bin/5fire.sh b/bin/5fire.sh new file mode 100755 index 0000000..472073d --- /dev/null +++ b/bin/5fire.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# set -x +declare -a coor pids +#coor[0]="0,0,0,560,650" +#coor[1]="0,443,108,560,650" +#coor[2]="0,878,197,560,650" +coor[0]="0,0,0,840,975" +coor[1]="0,863,0,840,975" +coor[2]="0,1712,0,840,975" +coor[3]="0,863,300,840,975" +coor[4]="0,1712,300,840,975" + + +# TODO: pids2wids function IN: pids OUT: associated windows ids + +ffox () { + if [ "$1" = "-v" ]; then + ps ax | egrep '[0-9] /usr/lib/firefox/firefox -no-remote -P (one|two|three|four|five) ' | grep -v grep | sed 's/^ *//g;s/ .*-P//g;s/ http.*//g' + else + ps ax | egrep '[0-9] /usr/lib/firefox/firefox -no-remote -P (one|two|three|four|five) ' | grep -v grep | sed 's/^ *//g;s/ .*//g' + fi +} + +rearrange_windows () { + ct=0 + while true; do + sleep 1 + wids="$(wmctrl -l -p | sed 's/ \+/|/g' | cut -d '|' -f 1,3 | egrep "\|(${pids[0]}|${pids[1]}|${pids[2]}|${pids[3]}|${pids[4]})$")" + l="$(echo "$wids" | wc -l)" + if [ $l -eq 5 ]; then + for i in $(seq 0 4); do + wid="$(echo "$wids" | grep "|${pids[$i]}\$" | cut -d '|' -f 1)" + wmctrl -i -r $wid -e ${coor[$i]} + echo wmctrl out: $? + done + break + fi + ct=$((ct + 1)) + if [ $ct -gt 10 ]; then + break + fi + done +} + +# +# MAIN +# +HOMEPAGE="http://dodo.birds.van/brisk/index.php" +if [ "$1" = "help" -o "$1" = "-h" -o "$1" = "--help" ]; then + echo "$0 - run firefoxes" + echo "$0 list [-v] - list firefoxes" + echo "$0 - send signal to firefoxes" + echo "$0 help - this help" +elif [ "$1" = "list" ]; then + ffox $2 +elif [ "$1" = "stop" -o "$1" = "cont" -o "$1" = "term" -o "$1" = "kill" ]; then + case "$1" in + stop) sig=-STOP ;; + cont) sig=-CONT ;; + term) sig=-TERM ;; + kill) sig=-KILL ;; + esac + + kill $sig $(ffox) +elif [ "$1" = "rearrange" ]; then + list="$($0 list -v)" + declare -a pids + ct=0 + for i in one two three four five; do + pids[$ct]="$(echo "$list" | grep -- " $i$" | sed 's/ .*//g')" + ct=$((ct + 1)) + done + rearrange_windows +elif [ $# -eq 0 ]; then + ct=0 + for i in one two three four five; do + firefox -no-remote -P $i "$HOMEPAGE?whoami=$i" & + pd="$!" + echo "$i: $pd" + pids[$ct]="$pd" + ct=$((ct + 1)) + done + + rearrange_windows +fi diff --git a/bin/brisk_explain_update.sh b/bin/brisk_explain_update.sh new file mode 100755 index 0000000..295c3de --- /dev/null +++ b/bin/brisk_explain_update.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -x +export PATH=/home/nastasi/bin:/usr/local/bin:/usr/bin:/bin:/usr/games +B_HOSTNAME="http://localhost/brisk" +# now="$(date -d '2014-01-21 23:56:00' +%s)" +now="$(date +%s)" + +to="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "($now / 86400) * 86400 + 7200 " | bc))" +from="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "($now / 86400) * 86400 + 7200 - (86400)" | bc))" +# to="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "$now + 7200 " | bc))" +# from="$(date +"%Y-%m-%d+%H:%M:%S" -d @$(echo "$now - 9200 " | bc))" + +curl -d 'pazz=yourpasswd' "$B_HOSTNAME/briskin5/stat-day.php?from=$from&to=$to" diff --git a/bin/brisk_pts_update.sh b/bin/brisk_pts_update.sh new file mode 100755 index 0000000..791521e --- /dev/null +++ b/bin/brisk_pts_update.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -x +B_HOSTNAME="http://localhost/brisk" +export PATH=/home/nastasi/bin:/usr/local/bin:/usr/bin:/bin:/usr/games +curl -d 'pazz=yourpasswd' "$B_HOSTNAME/briskin5/statadm.php" -- 2.17.1