From 5d4ca7c0dcfaf8c260bef16bcc3a6ec992e59ac2 Mon Sep 17 00:00:00 2001 From: Banana Date: Thu, 18 Jan 2018 15:01:24 +0100 Subject: [PATCH] new script and some link update --- apache/auto-index/README | 2 +- .../improved-directory-index.htaccess | 2 +- bash/colour-text-echo.sh | 2 +- bash/for-loop.sh | 2 +- bash/move-window.sh | 92 +++++++++++++++++++ bash/twitter-backup.sh | 2 +- bash/twitter-oauth-timeline.sh | 4 +- bash/waiting-for-user-confirmation.sh | 2 +- ...ing-for-user-confirmation_without-enter.sh | 2 +- 9 files changed, 101 insertions(+), 9 deletions(-) create mode 100755 bash/move-window.sh diff --git a/apache/auto-index/README b/apache/auto-index/README index 15d4b9a..23e42c4 100644 --- a/apache/auto-index/README +++ b/apache/auto-index/README @@ -5,7 +5,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net A better directory index page for apache mod_autoindex. diff --git a/apache/auto-index/improved-directory-index.htaccess b/apache/auto-index/improved-directory-index.htaccess index 6740fa3..8b85a08 100644 --- a/apache/auto-index/improved-directory-index.htaccess +++ b/apache/auto-index/improved-directory-index.htaccess @@ -5,7 +5,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net Options +Indexes diff --git a/bash/colour-text-echo.sh b/bash/colour-text-echo.sh index d02a9ea..1c216af 100644 --- a/bash/colour-text-echo.sh +++ b/bash/colour-text-echo.sh @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2013 https://github.com/jumpin-banana +# 2013 http://www.bananas-playground.net # this function prints the given string in the given colour in a bash shell # either include this function directly into your script or source it as an diff --git a/bash/for-loop.sh b/bash/for-loop.sh index f52ea9b..7f47041 100644 --- a/bash/for-loop.sh +++ b/bash/for-loop.sh @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net #Hier eine Schleife die für jede Ausgabe vom dem Befehl in `` eine Aktion ausführt. #Hier gibt sie jeden Ordner in dem Aktuellen Verzeichnis aus. diff --git a/bash/move-window.sh b/bash/move-window.sh new file mode 100755 index 0000000..5b031d9 --- /dev/null +++ b/bash/move-window.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Move the current window to the next monitor. +# +# original code from: +# https://unix.stackexchange.com/questions/48456/xfce-send-window-to-other-monitor-on-keystroke/322904#322904 + +# run script with -r or -l as a keyboard shurtcut and the current active window will be move. +# works with horizontal monitors. Needs to be improved to work with vertical ones. + +# needs the following applications +# xdpyinfo +# xdotool +# xprop +# wmctrl +# xwininfo + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +# +# You should have received a copy of the +# COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# along with this program. If not, see http://www.sun.com/cddl/cddl.html + +# 2018 http://www.bananas-playground.net + +screen_width=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $7 }') +screen_height=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $8 }') +window_id=$(xdotool getactivewindow) + +case $1 in + -l ) + display_width=$((screen_width / 3 * 2)) ;; + -r ) + display_width=$((screen_width / 3)) ;; +esac + +# Remember if it was maximized. +window_state=$(xprop -id $window_id _NET_WM_STATE | awk '{ print $3 }') + +# Un-maximize current window so that we can move it +wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz + +# Read window position +x=$(xwininfo -id $window_id | awk '/Absolute upper-left X:/ { print $4 }') +y=$(xwininfo -id $window_id | awk '/Absolute upper-left Y:/ { print $4 }') + +# Subtract any offsets caused by window decorations and panels +x_offset=$(xwininfo -id $window_id | awk '/Relative upper-left X:/ { print $4 }') +y_offset=$(xwininfo -id $window_id | awk '/Relative upper-left Y:/ { print $4 }') +x=$((x - x_offset)) +y=$((y - y_offset)) + +# Fix Chromium app view issue of small un-maximized size +width=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $4 }') +if [ "$width" -lt "150" ]; then + display_width=$((display_width + 150)) +fi + +# Compute new X position +new_x=$((x + display_width)) +# Compute new Y position +new_y=$((y + screen_height)) + +# If we would move off the right-most monitor, we set it to the left one. +# We also respect the window's width here: moving a window off more than half its width won't happen. +if [ $((new_x + width / 2)) -gt $screen_width ]; then + new_x=$((new_x - screen_width)) +fi + +height=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $5 }') +if [ $((new_y + height / 2)) -gt $screen_height ]; then + new_y=$((new_y - screen_height)) +fi + +# Don't move off the left side. +if [ $new_x -lt 0 ]; then + new_x=0 +fi + +# Don't move off the bottom +if [ $new_y -lt 0 ]; then + new_y=0 +fi + +# Move the window +xdotool windowmove $window_id $new_x $new_y + +# Maintain if window was maximized or not +if [ "${window_state}" = "_NET_WM_STATE_MAXIMIZED_HORZ," ]; then + wmctrl -ir $window_id -b add,maximized_vert,maximized_horz +fi diff --git a/bash/twitter-backup.sh b/bash/twitter-backup.sh index 0794fdf..6873052 100644 --- a/bash/twitter-backup.sh +++ b/bash/twitter-backup.sh @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net # this script should be run with a cronjob once a day to get the rss streem for the given screenname diff --git a/bash/twitter-oauth-timeline.sh b/bash/twitter-oauth-timeline.sh index ba57060..2faf918 100644 --- a/bash/twitter-oauth-timeline.sh +++ b/bash/twitter-oauth-timeline.sh @@ -1,5 +1,5 @@ #!/bin/bash -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE # @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2013 https://github.com/jumpin-banana +# 2013 http://www.bananas-playground.net # # fetch the timeline from given twitter user diff --git a/bash/waiting-for-user-confirmation.sh b/bash/waiting-for-user-confirmation.sh index e75dba1..85cb28a 100644 --- a/bash/waiting-for-user-confirmation.sh +++ b/bash/waiting-for-user-confirmation.sh @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net # # wait for user input with either Y or y to proceed diff --git a/bash/waiting-for-user-confirmation_without-enter.sh b/bash/waiting-for-user-confirmation_without-enter.sh index 497f15c..8b62def 100644 --- a/bash/waiting-for-user-confirmation_without-enter.sh +++ b/bash/waiting-for-user-confirmation_without-enter.sh @@ -7,7 +7,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2011 https://github.com/jumpin-banana +# 2011 http://www.bananas-playground.net # # wait for user input with either Y or y to proceed -- 2.39.5