diff --git a/bin/tsvsummary b/bin/tsvsummary new file mode 120000 index 0000000..62e4d3e --- /dev/null +++ b/bin/tsvsummary @@ -0,0 +1 @@ +../tsv/tsvsummary \ No newline at end of file diff --git a/skel/disp b/skel/disp index a5bd0a1..68aa00d 100644 --- a/skel/disp +++ b/skel/disp @@ -4,17 +4,60 @@ LAPTOP=LVDS1 ANALOG=VGA1 DIGITAL=HDMI1 + # You hay have to change ANALOG/DIGITAL in the outputs, especially for Workstation choices +# The choices may be the same! +PRESENTATION=$ANALOG +WORKSTATION=$ANALOG + +#Helper functions when using lxpanel (Lubuntu / LXDE) +function reset_lxpanel() { + if lxpanel_running; then + PROFILE=$( lxpanel_profile ) + sed -i -e 's,edge=.*,edge=bottom,' -e "s,allign=.*,allign=left," -e "s,widthtype=.*,widthtype=percent," -e "s,width=.*,width=100," $HOME/.config/lxpanel/${PROFILE}/panels/panel + fi +} + +function side_lxpanel() { + if lxpanel_running; then + PROFILE=$( lxpanel_profile ) + sleep 1 + LAPTOPWIDTH=$( xrandr -q | grep $LAPTOP | cut -d" " -f3 | cut -dx -f1 ) + sed -i -e 's,edge=.*,edge=bottom,' -e "s,allign=.*,allign=$1," -e "s,widthtype=.*,widthtype=pixel," -e "s,width=.*,width=$LAPTOPWIDTH," $HOME/.config/lxpanel/${PROFILE}/panels/panel + echo "Warning: if LAPTOP has more pixels in the vertical direction, panel is invisible! change configuration of this script, and/or current setup ( lxpanelctl config )" + fi +} + +function restart_lxpanel() { + if lxpanel_running; then + LXCMD=$( ps -ocommand= --pid $( pgrep -u $USER -n lxpanel ) ) + lxpanelctl restart + sleep 2 + lxpanel_running || { + echo "lxpanel segfaulted. restarting..." + $LXCMD &> /dev/null & + } + fi +} + +function lxpanel_running() { + pgrep -u $USER -n lxpanel &> /dev/null +} +function lxpanel_profile() { + ps -ocommand= --pid $( pgrep -u $USER -n lxpanel ) | sed 's/.*--profile \([^ ]\+\).*/\1/' +} if [ -z "$1" ] then echo 'Choose display mode: 1) Laptop only 2) Presentation (2nd arg for gamma correction) - 3) Workstation with 2nd screen - 4) External display only + 3) Workstation: 2nd screen on the right + 4) Workstation: 2nd screen on the left + 5) Workstation: external display only ' - read i + read -N 1 i + echo "" else i=$1 fi @@ -22,11 +65,15 @@ if [ -z "$2" ] then g=1 else g=$2 fi - +oppos=left +if [ "$2" = "left" ] +then oppos=right +fi case $i in - 1) xrandr --output $LAPTOP --auto --gamma $g:$g:$g --output $ANALOG --off --output $DIGITAL --off ;; - 2) xrandr --output $LAPTOP --mode 1024x768 --pos 0x0 --output $ANALOG --mode 1024x768 --pos 0x0 --gamma $g:$g:$g ;; - 3) xrandr --output $LAPTOP --auto --output $ANALOG --auto --right-of $LAPTOP ;; - 4) xrandr --output $LAPTOP --off --output $ANALOG --auto ;; + 1) xrandr --output $LAPTOP --auto --gamma $g:$g:$g --output $PRESENTATION --off --output $WORKSTATION --off; reset_lxpanel; ;; + 2) xrandr --output $LAPTOP --mode 1024x768 --pos 0x0 --output $PRESENTATION --mode 1024x768 --pos 0x0 --gamma $g:$g:$g; reset_lxpanel; ;; + 3) xrandr --output $LAPTOP --auto --output $WORKSTATION --auto --right-of $LAPTOP; side_lxpanel right; ;; + 4) xrandr --output $LAPTOP --auto --output $WORKSTATION --auto --left-of $LAPTOP; side_lxpanel left; ;; + 5) xrandr --output $LAPTOP --off --output $WORKSTATION --auto; reset_lxpanel; ;; esac - +restart_lxpanel diff --git a/tsv/tsvsummary b/tsv/tsvsummary index b1bfddf..070559f 100755 --- a/tsv/tsvsummary +++ b/tsv/tsvsummary @@ -11,8 +11,8 @@ Usage: tsvsummary [-c column] [-t type] tsv_file -t Type of statistics: mean, max, min, sum, stdev, nas, unique -h Help ' - } + TYPEOF=mean TYPELIST=( mean max min sum stdev nas unique ) while getopts c:ht: opt @@ -45,6 +45,9 @@ then usage exit 1 fi +which ncsv &> /dev/null || ( echo ncsv required: "https://code.google.com/p/nicecsv/"; exit 1 ) +which csvcut &> /dev/null || ( echo csvkit required: "https://csvkit.readthedocs.org/"; exit 1 ) + if [ -z "$LABEL" ] then ncsv --stat "$1" | sed -n "1p;/^$TYPEOF/Ip" exit