This commit is contained in:
2026-02-07 01:40:31 +01:00
commit 7414910b00
109 changed files with 3903 additions and 0 deletions

97
bin/jgbrowser Executable file
View File

@@ -0,0 +1,97 @@
#!/usr/bin/env bash
# Daniel Napora 2020 - 2025 <danieln@maboxlinux.org>
. "$HOME"/.config/mabox/mabox.conf
if [ -f "$HOME/.config/gtk-3.0/bookmarks" ];then
BOOKMARKS="$HOME/.config/gtk-3.0/bookmarks"
else
BOOKMARKS="$HOME/.gtk-bookmarks"
fi
case $LANG in
pl*)
DIRECTORIES="Katalogi"
FILES="Pliki"
ADDBOOKMARK="Dodaj do zakładek"
QDIRSTAT="QDirStat (statystyki katalogów)"
OPENDIR="Otwórz w menadżerze plików"
OPENTERM="Otwórz w terminalu"
;;
es*)
DIRECTORIES="Directorios"
FILES="Archivos"
ADDBOOKMARK="Agregar a marcadores"
QDIRSTAT="QDirStat (directory statistics)"
OPENDIR="Abrir Gestor de archivos aquí"
OPENTERM="Abrir terminal aquí"
;;
*)
DIRECTORIES="Directories"
FILES="Files"
ADDBOOKMARK="Add to Bookmarks"
QDIRSTAT="QDirStat (directory statistics)"
OPENDIR="Open filemanager here"
OPENTERM="Open terminal here"
;;
esac
: "${JGMENU_RESOURCE_OPENER="xdg-open"}"
DIRECTORY=${1:-$HOME}
OPTION=${2:-""}
# If '$DIRECTORY' is '/', unset it to avoid '//'.
[[ $DIRECTORY == / ]] && DIRECTORY=
if [ "$jgbrowser_show_hidden" == false ];then
for item in "$DIRECTORY"/*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\" \"${2}\")")
else
if [[ -f $item ]]; then
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
fi
fi
done
else
for item in "$DIRECTORY"/* "$DIRECTORY"/.[^.]*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\" \"${2}\")")
else
if [[ -f $item ]]; then
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
fi
fi
done
fi
printf "%b\n" "^sep(<small><i>${DIRECTORY:-/}</i></small>)"
printf "%b\n" " $OPENDIR,${JGMENU_RESOURCE_OPENER} \"${DIRECTORY:-/}\""
printf "%b\n" "<big></big> $OPENTERM,exo-open --launch TerminalEmulator --working-directory=\"${DIRECTORY:-/}\""
if [[ "${2}" == "-q" ]];then
printf "%b\n" "^sep()"
printf "%b\n" "󰀻 ${QDIRSTAT},qdirstat ${DIRECTORY:-/}"
elif [[ "${2}" == "-b" ]];then
:
else
#printf "%b\n" " ${ADDBOOKMARK},\"\"\"echo \" ${DIRECTORY##*/},^pipe(jgbrowser ${DIRECTORY:-/})\" >> $HOME/.config/mabox/places.csv;mb-places -s\"\"\""
printf "%b\n" "^sep()"
printf "%b\n" " ${ADDBOOKMARK},\"\"\"echo \"file://${DIRECTORY:-/} ${DIRECTORY##*/} \" >> ${BOOKMARKS};mb-places -s\"\"\""
fi
#printf "%b\n" " $OPENTERM,terminator --working-directory=\"${DIRECTORY:-/}\""
if [ ${#dirs[@]} -ne 0 ]; then
printf "%b\n" "^sep($DIRECTORIES <small>(${#dirs[@]})</small>)"
printf "%s\n" "${dirs[@]/&/&amp;}"
fi
if [ ${#files[@]} -ne 0 ]; then
printf "%b\n" "^sep($FILES <small>(${#files[@]})</small>)"
#printf "%s\n" "${files[@]}"
#okfiles=("${files[@]/</ &lt;}")
printf "%s\n" "${files[@]/&/&amp;}"
fi

34
bin/jgtile Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# jgtile - jgmenu simple gui for winfuncs tile script
# Copyright (C) 2020 napcok <napcok@gmail.com>
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
ICONDIR="/usr/share/mb-jgtools/jgtile"
MENU_PADDING_TOP=8
MENU_HALIGN="center"
MENU_VALIGN="center"
#JGWIDTH=175
jgmenu_item_height=30
jgmenu_icon_size=40
item_height_factor=400
icons=1
iconmargin=4
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
^sep(Tile helper (W-A-t))
Tile,winfuncs tile,$ICONDIR/tile.png
Tile Two (equal),winfuncs tiletwo,$ICONDIR/tiletwo.png
Tile Two (Left wider),winfuncs tiletwol,$ICONDIR/tiletwol.png
Tile Two (Right wider),winfuncs tiletwor,$ICONDIR/tiletwor.png
Tile Three,winfuncs tilethree,$ICONDIR/tilethree.png
Tile Three vertical,winfuncs tilethreev,$ICONDIR/tilethreev.png
Stack Two, winfuncs stacktwo,$ICONDIR/stacktwo.png
Cascade, winfuncs cascade,$ICONDIR/cascade.png
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0

1314
bin/mb-jgtools Executable file

File diff suppressed because it is too large Load Diff

255
bin/mb-reset Executable file
View File

@@ -0,0 +1,255 @@
#!/bin/bash
# Daniel Napora 2021-24 <napcok@gmail.com>
#: mb-reset - reset/update user config files to (current) distro defaults.
#: It only affects files shipped with Mabox.
#: Be aware that you may loose your own customizations (if any).
#:
#: Usage: mb-reset option
#:
#: Options:
#: Compare mode (safe - you decide what changes to pick):
#: -c - compare files using meld GUI (if installed)
#: It lets you see changes and decide which one to pick or not.
#: Works with rc.xml,bashrc and autostart files
#: Usage: mb-reset -c obrcxml | autostart | bashrc
#: Overwrite mode:
#: obrcxml - rc.xml default OpenBox configuration file
#: obautostart - default autostart file
#: bashrc - bash config file (~/.bashrc)
#: picom - install/override new picom config with animations
#: terminator - terminator config
#: conky - overwrite conky config files in ~/.config/conky/
#: tint2 - overwrite tint2 panel config files in ~/.config/tint2/
#: mainmenu - overwrite main menu files (favorites.csv)
#: leftpanel - left panel custom commands
#: rightpanel - right panel custom commands
#: allmenus - overvrite all menus, panels and exit dialog
#: logout - logout dialog
#: blobthemes - overwrite default themes for theme manager
#: skippy-xd - window & desktop switcher config file
##: For Labwc only (alpha):
##: labwc - labwc session configs
##: labwc-theme - labwc theme for Mabox
##: mabox-labwc - mabox-labwc session configs
##: waybar - waybar configs
if (( $EUID == 0 )); then
echo "Please run script as user, not root!"
exit
fi
case $LANG in
pl*) LNGDIR="pl";;
es*) LNGDIR="es";;
*) LNGDIR="en";;
esac
me="${0##*/} $@"
isPkgInstalled(){
if pacman -Qi "$1" &> /dev/null;then
:
else
echo -e "Package ${1} is not installed!!! \nInstall it by command:\n yay -S ${1}\nThen run: '$me' again"
exit 0
fi
}
__usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
__compare() {
command -v meld >/dev/null 2>&1 || { echo "mb-reset compare mode requires meld. Install it and try again. (yay -S meld)" >&2; exit 1; }
case "$1" in
obrcxml)
cp $HOME/.config/openbox/rc.xml{,.bak."$(date +%Y%m%d-%H%M%S)"}
meld /usr/share/mabox/common/rc.xml ~/.config/openbox/rc.xml &
;;
autostart)
cp $HOME/.config/openbox/autostart{,.bak."$(date +%Y%m%d-%H%M%S)"}
meld /usr/share/mabox/common/autostart ~/.config/openbox/autostart &
;;
bashrc)
cp $HOME/.bashrc{,.bak."$(date +%Y%m%d-%H%M%S)"}
meld /usr/share/mabox/common/.bashrc ~/.bashrc &
;;
conky)
meld /usr/share/mabox/lang/$LNGDIR/.config/conky/ ~/.config/conky/ &
;;
*)
echo "Compare "
echo "Usage: mb-reset -c obrcxml|autostart|bashrc"
;;
esac
}
__allmenus() {
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/settings* $HOME/.config/mabox/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/jgmenu/*.csv $HOME/.config/jgmenu/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/favorites.csv $HOME/.config/mabox/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/places* $HOME/.config/mabox/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/right* $HOME/.config/mabox/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/exit.csv $HOME/.config/mabox/
mb-setvar places_menusettingspipe=true
mb-setvar places_sysinfopipe=true
mb-setvar places_conkypipe=true
mb-setvar places_tint2pipe=true
mb-setvar places_jgdesktops=true
mb-setvar places_jgdeskmngr=true
mb-setvar places_softwarepipe=true
}
__mainmenu() {
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/jgmenu/*.csv $HOME/.config/jgmenu/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/favorites.csv $HOME/.config/mabox/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/setting*.csv $HOME/.config/mabox/
}
__leftpanel() {
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/places* $HOME/.config/mabox/
mb-setvar places_menusettingspipe=true
mb-setvar places_sysinfopipe=true
mb-setvar places_keyspipe=true
mb-setvar places_sshpipe=true
mb-setvar places_conkypipe=true
mb-setvar places_tint2pipe=true
mb-setvar places_jgdesktops=true
mb-setvar places_jgdeskgrid=true
mb-setvar places_softwarepipe=true
}
__rightpanel() {
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/right* $HOME/.config/mabox/
}
__logout() {
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/mabox/exit.csv $HOME/.config/mabox/
}
__tint2() {
mkdir -p $HOME/.config/fontconfig/conf.d
rsync -a /usr/share/mabox/common/66-symbols.conf $HOME/.config/fontconfig/conf.d/
fc-cache
rsync -a /usr/share/mabox/common/volumettf $HOME/.config/tint2/scripts/
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/tint2/*.tint2rc $HOME/.config/tint2/
TYPE=$(cat /sys/class/dmi/id/chassis_type)
case "$TYPE" in
8|9|10|14):;;
*)
# fix tint2 battery indicator bug spawning notifications even if there is no battery
sd "battery_low_cmd =.*$" "battery_low_cmd =" "$HOME"/.config/tint2/*.tint2rc
;;
esac
killall -SIGUSR1 tint2
}
__conky() {
cp $HOME/.config/conky/conky-sessionfile{,.bak."$(date +%Y%m%d-%H%M%S)"}
cp $HOME/.config/conky/saved-sessions{,.bak."$(date +%Y%m%d-%H%M%S)"}
rsync -a /usr/share/mabox/lang/$LNGDIR/.config/conky/* $HOME/.config/conky/
killall -SIGUSR1 conky
}
__blobthemes() {
case "$LANG" in
pl*)
rsync -a /usr/share/mabox/lang/pl/.config/blob/ $HOME/.config/blob/
;;
es*)
rsync -a /usr/share/mabox/lang/es/.config/blob/ $HOME/.config/blob/
;;
*)
rsync -a /usr/share/mabox/lang/en/.config/blob/ $HOME/.config/blob/
;;
esac
}
__obrcxml() {
cp $HOME/.config/openbox/rc.xml{,.bak."$(date +%Y%m%d-%H%M%S)"}
rsync -a /usr/share/mabox/common/rc.xml $HOME/.config/openbox/
openbox --reconfigure
}
__obautostart() {
cp $HOME/.config/openbox/autostart{,.bak."$(date +%Y%m%d-%H%M%S)"}
rsync -a /usr/share/mabox/common/autostart $HOME/.config/openbox/
}
__bashrc() {
cp $HOME/.bashrc{,.bak."$(date +%Y%m%d-%H%M%S)"}
rsync -a /usr/share/mabox/common/.bashrc $HOME/
}
__terminator() {
rsync -a /usr/share/mabox/common/terminator/* $HOME/.config/terminator/
}
__picom() {
mkdir -p $HOME/.config/picom/include
rsync -a /usr/share/mabox/common/picom/include/* $HOME/.config/picom/include/
rsync -a /usr/share/mabox/common/picom/configs/mabox-jaskier.conf $HOME/.config/picom/configs/
}
__skippy-xd() {
isPkgInstalled 'skippy-xd'
mkdir -p "$HOME/.config/skippy-xd"
if rsync -a /usr/share/mabox/common/skippy-xd.rc "$HOME/.config/skippy-xd/" &>/dev/null;then
echo "Skippy-xd config file updated!"
if pgrep -fa "skippy-xd --start-daemon" &>/dev/null;then
skippy-xd --config-reload &>/dev/null && echo "Skippy-xd daemon is running. Config reloaded!"
else
skippy-xd --start-daemon > /dev/null 2>&1 &
echo "Skippy-xd daemon started!"
fi
else
echo "Something went wrong! Config not updated"
fi
}
__labwc() {
mkdir -p $HOME/.config/labwc
rsync -a /etc/skel/.config/labwc/* $HOME/.config/labwc/
}
__mabox-labwc() {
mkdir -p $HOME/.config/mabox-labwc
rsync -a /etc/skel/.config/mabox-labwc/* $HOME/.config/mabox-labwc/
}
__waybar() {
mkdir -p $HOME/.config/waybar
rsync -a /etc/skel/.config/waybar/* $HOME/.config/waybar/
}
__labwc-theme() {
mkdir -p $HOME/.local/share/themes/Mabox-Labwc/openbox-3
rsync -a /etc/skel/.local/share/themes/Mabox-Labwc/openbox-3/* $HOME/.local/share/themes/Mabox-Labwc/openbox-3/
}
case "$1" in
-c|check) __compare "$2";;
allmenus) __allmenus ;;
mainmenu) __mainmenu ;;
leftpanel) __leftpanel ;;
rightpanel) __rightpanel ;;
logout) __logout ;;
tint2) __tint2 ;;
conky) __conky ;;
blobthemes) __blobthemes ;;
obrcxml) __obrcxml ;;
obautostart) __obautostart ;;
bashrc) __bashrc ;;
terminator) __terminator ;;
picom) __picom ;;
skippy-xd) __skippy-xd;;
labwc) __labwc ;;
mabox-labwc) __mabox-labwc ;;
waybar) __waybar ;;
labwc-theme) __labwc-theme ;;
-h|--help) __usage ;;
*) __usage ;;
esac
exit 0

77
bin/mb-screenrec Executable file
View File

@@ -0,0 +1,77 @@
#!/bin/bash
#: mb-screenrec - very simple screen recorder
CNF_FILE="$HOME"/.config/mabox/mb-screenrec.conf
. "$CNF_FILE"
DATE=$(date +%Y%m%d_%H-%M-%S)
FRAMERATE=${framerate:-30}
EXT=${container:-webm}
AUDIO=${record_audio:-no}
SCREEN_SIZE=$(xdpyinfo | awk '/^ +dimensions/ {print $2}')
# Alternative: xrandr | grep 'current' | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'
RECDIR="$(xdg-user-dir VIDEOS)/Recordings"
mkdir -p $RECDIR
if [ "$AUDIO" == "yes" ];then
AUDIOCMD="-f pulse -ac 2 -i default"
else
AUDIOCMD=""
fi
show_stop_icon () {
case "$LANG" in
pl*) STOP_INFO="Zatrzymaj nagrywanie";;
*) STOP_INFO="Click to stop recording";;
esac
yad --notification --image media-playback-stop --text "${STOP_INFO}"
kill $FFMPEG_PID
wait $FFMPEG_PID
xdg-open $RECDIR
}
rec_full () {
ffmpeg -f x11grab \
-video_size $SCREEN_SIZE \
-framerate $FRAMERATE \
-i :0.0+0,0 ${AUDIOCMD} \
${RECDIR}/rec_${DATE}.${EXT} &
FFMPEG_PID=$!
show_stop_icon
}
get_area () {
read X Y W H <<<"$(slop -l -b 3 --color=0.3,0.4,0.6,0.4 -f '%x %y %w %h')"
}
sel_cancelled () {
notify-send.sh -i mbcc "Error" "Selection was cancelled by keystroke or right-click."
}
rec_area () {
get_area
if [ "$X" != "" ];then
ffmpeg -f x11grab \
-video_size ${W}x${H} \
-framerate $FRAMERATE \
-i :0.0+${X},${Y} ${AUDIOCMD} \
${RECDIR}/rec_${DATE}.${EXT} &
FFMPEG_PID=$!
show_stop_icon
else
sel_cancelled
fi
}
case "$1" in
-f|--fullscreen) rec_full;;
-a|--area) rec_area;;
*) ;;
esac

18
bin/obtheme2jgmenu Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
ob_file=$HOME/.config/openbox/rc.xml
[[ -f $ob_file ]] && wm_theme=$(awk '/<theme>/ {while (getline n) {if (match(n, /<name>/)){l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$ob_file")
#Run only if theme doesn't exist
CONFFILE="$HOME/.config/mabox/jgobthemes/${wm_theme// /_}.colorrc"
if [ ! -f "$CONFFILE" ]; then
jgmenu_run init --apply-obtheme
grep -f $HOME/.config/mabox/jgobthemes/example.txt $HOME/.config/jgmenu/jgmenurc | sponge $HOME/.config/mabox/jgobthemes/${wm_theme// /_}.colorrc
echo "menu_gradient_pos = none" >> "$CONFFILE"
echo "color_menu_bg_to = #222222 100" >> "$CONFFILE"
sd '^#' '' "$CONFFILE"
fi

28
bin/oneshot Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Based on: https://askubuntu.com/questions/211750/taking-screenshots-of-all-or-specific-virtual-desktops-workspaces-or-windows
SLEEP="5"
DESTDIR=$(xdg-user-dir PICTURES)
COL=1
EXT="webp"
DATE=$(date +"%Y%m%d-%H%M%S")
eval $(xdotool getdisplaygeometry --shell)
NUMDESK=$(xdotool get_num_desktops)
DESK=0
while [[ "$DESK" -lt "$NUMDESK" ]];
do
xdotool set_desktop $DESK;
sleep ${SLEEP};
scrot -o "/tmp/desktop${DESK}.${EXT}";
DESK=$((DESK+1));
done
cd "${DESTDIR}"
montage /tmp/desktop*.${EXT} -tile "${COL}"x -geometry "${WIDTH}"x"${HEIGHT}"+4+4 workspaces_"${DATE}".${EXT}
rm /tmp/desktop*.${EXT}
viewnior workspaces_${DATE}.${EXT} &

438
bin/winfuncs Executable file
View File

@@ -0,0 +1,438 @@
#!/bin/bash
#todo:
# cancel for tile function
# determine what windows are maximized and re-max after the "window select" function
# determine what windows are non-resizable by the user so that the script doesn't resize them
# cascade also shaded windows
# winfuncsh select
# winfuncs tile
# winfuncs tiletwo
# winfuncs tiletwol
# winfuncs tiletwor
# winfuncs tilethree
# winfuncs tilethreev
# winfuncs stacktwo
# winfuncs cascade
# winfuncs showdesktop
# set gaps (0 removes gaps)
outer_gaps=2
inner_gaps=2
# set gaps for 'select' mode
expose_gaps=20
# set desktop dimensions
display_width=$(xdotool getdisplaygeometry | cut -d" " -f1)
display_height=$(xdotool getdisplaygeometry | cut -d" " -f2)
# desktop height without panel(s)
desktop_height=$(xprop -root _NET_WORKAREA | awk '{ print $6 }' | cut -d"," -f1)
# window decorations
window_id=$(xdotool getactivewindow)
titlebar_offset=$(xwininfo -id "$window_id" | awk '/Relative upper-left Y:/ { print $4 }')
# top panel
top_bar=$(xprop -root _NET_WORKAREA | awk '{ print $4 }' | cut -d"," -f1)
# bottom panel (not needed)
bottom_bar=`expr $display_height - $desktop_height - $top_bar`
function get_desktop_dim {
if (( ${#DIM[@]} == 0 )) ; then
DIM=(`expr $display_width - $outer_gaps \* 2` `expr $desktop_height - $outer_gaps \* 2`)
fi
}
# which workspace we're on
function get_workspace {
if [[ "$DTOP" == "" ]] ; then
DTOP=`xdotool get_desktop`
fi
}
function is_desktop {
xwininfo -id "$*" | grep '"Desktop"'
return "$?"
}
function get_visible_window_ids {
if (( ${#WDOWS[@]} == 0 )) ; then
WDOWS=(`xdotool search --desktop $DTOP --onlyvisible "" 2>/dev/null`)
fi
}
function win_showdesktop {
get_workspace
get_visible_window_ids
command="search --desktop $DTOP \"\""
if (( ${#WDOWS[@]} > 0 )) ; then
command="$command windowminimize %@"
else
command="$command windowraise %@"
fi
echo "$command" | xdotool -
}
function win_tile_two {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
half_w=`expr ${DIM[0]} / 2`
win_h=${DIM[1]}
commands="windowsize $wid1 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid2 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 `expr $half_w + $outer_gaps + $inner_gaps` `expr $top_bar + $outer_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile_two_left {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
half_w=`expr ${DIM[0]} / 3`
win_h=${DIM[1]}
commands="windowsize $wid1 `expr $half_w \* 2 - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid2 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 `expr $half_w \* 2 + $outer_gaps + $inner_gaps` `expr $top_bar + $outer_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile_two_right {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
half_w=`expr ${DIM[0]} / 3`
win_h=${DIM[1]}
commands="windowsize $wid1 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid2 `expr $half_w \* 2 - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 `expr $half_w + $outer_gaps + $inner_gaps` `expr $top_bar + $outer_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_stack_two {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
win_w=${DIM[0]}
half_h=`expr ${DIM[1]} / 2`
commands="windowsize $wid1 `expr $win_w` `expr $half_h - $titlebar_offset - $inner_gaps`"
commands="$commands windowsize $wid2 `expr $win_w` `expr $half_h - $titlebar_offset - $inner_gaps`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 $outer_gaps `expr $half_h + $top_bar + $outer_gaps + $inner_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile_three {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
wid3=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid3" && return
win_h=${DIM[1]}
half_w=`expr ${DIM[0]} / 2`
half_h=`expr ${win_h} / 2`
commands="windowsize $wid1 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid2 `expr $half_w - $inner_gaps` `expr $half_h - $titlebar_offset - $inner_gaps`"
commands="$commands windowsize $wid3 `expr $half_w - $inner_gaps` `expr $half_h - $titlebar_offset - $inner_gaps`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 `expr $half_w + $outer_gaps + $inner_gaps` `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid3 `expr $half_w + $outer_gaps + $inner_gaps` `expr $half_h + $top_bar + $outer_gaps + $inner_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
commands="$commands windowraise $wid3"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid3 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile_three_v {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
wid3=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid3" && return
win_h=${DIM[1]}
half_w=`expr ${DIM[0]} / 3`
commands="windowsize $wid1 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid2 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowsize $wid3 `expr $half_w - $inner_gaps` `expr $win_h - $titlebar_offset`"
commands="$commands windowmove $wid1 $outer_gaps `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid2 `expr $half_w + $outer_gaps + $inner_gaps / 2` `expr $top_bar + $outer_gaps`"
commands="$commands windowmove $wid3 `expr $half_w \* 2 + $outer_gaps + $inner_gaps` `expr $top_bar + $outer_gaps`"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
commands="$commands windowraise $wid3"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid3 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
get_desktop_dim
# determine how many rows and columns we need
cols=`echo "sqrt(${#WDOWS[@]})" | bc`
rows=$cols
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
cols=`expr $cols + 1`
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
rows=`expr $rows + 1`
wins=`expr $rows \* $cols`
fi
fi
(( $cols < 1 )) && cols=1;
(( $rows < 1 )) && rows=1;
win_w=`expr ${DIM[0]} / $cols`
win_h=`expr ${DIM[1]} / $rows`
# do tiling
x=0; y=0; commands=""
for window in ${WDOWS[@]} ; do
wmctrl -i -r $window -b remove,maximized_vert,maximized_horz
commands="$commands windowsize $window `expr $win_w - $inner_gaps \* 2` `expr $win_h - $titlebar_offset - $inner_gaps \* 2`"
commands="$commands windowmove $window `expr $x \* $win_w + $outer_gaps` `expr $y \* $win_h + $top_bar + $outer_gaps`"
x=`expr $x + 1`
if (( $x > `expr $cols - 1` )) ; then
x=0
y=`expr $y + 1`
fi
done
echo "$commands" | xdotool -
}
function expose {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
get_desktop_dim
# determine how many rows and columns we need
cols=`echo "sqrt(${#WDOWS[@]})" | bc`
rows=$cols
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
cols=`expr $cols + 1`
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
rows=`expr $rows + 1`
wins=`expr $rows \* $cols`
fi
fi
(( $cols < 1 )) && cols=1;
(( $rows < 1 )) && rows=1;
win_w=`expr ${DIM[0]} / $cols`
win_h=`expr ${DIM[1]} / $rows`
# do tiling
x=0; y=0; commands=""
for window in ${WDOWS[@]} ; do
wmctrl -i -r $window -b remove,maximized_vert,maximized_horz
commands="$commands windowsize $window `expr $win_w - $expose_gaps \* 2` `expr $win_h - $titlebar_offset - $expose_gaps \* 2`"
commands="$commands windowmove $window `expr $x \* $win_w + $expose_gaps` `expr $y \* $win_h + $top_bar + $expose_gaps`"
x=`expr $x + 1`
if (( $x > `expr $cols - 1` )) ; then
x=0
y=`expr $y + 1`
fi
done
echo "$commands" | xdotool -
}
function win_cascade {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
x=0; y=0; commands=""
for window in ${WDOWS[@]} ; do
wmctrl -i -r $window -b remove,maximized_vert,maximized_horz
commands="$commands windowsize $window 1024 640"
commands="$commands windowmove $window `expr $x + $outer_gaps` `expr $y + $top_bar + $outer_gaps`"
x=`expr $x + 100`
y=`expr $y + 80`
done
echo "$commands" | xdotool -
}
function win_select {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
# store window positions and widths
i=0
for window in ${WDOWS[@]} ; do
GEO=`xdotool getwindowgeometry $window | grep Geometry | sed 's/.* \([0-9].*\)/\1/g'`;
height[$i]=`echo $GEO | sed 's/\(.*\)x.*/\1/g'`
width[$i]=`echo $GEO | sed 's/.*x\(.*\)/\1/g'`
# ( xwininfo gives position not ignoring titlebars and borders, unlike xdotool )
POS=(`xwininfo -stats -id $window | grep 'geometry ' | sed 's/.*[-+]\([0-9]*[-+][0-9*]\)/\1/g' | sed 's/[+-]/ /g'`)
posx[$i]=${POS[0]}
posy[$i]=${POS[1]}
i=`expr $i + 1`
done
# tile windows
expose
# select a window
wid=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid" && return
# restore window positions and widths
i=0; commands=""
for (( i=0; $i<${#WDOWS[@]}; i++ )) ; do
commands="$commands windowsize ${WDOWS[i]} ${height[$i]} ${width[$i]}"
commands="$commands windowmove ${WDOWS[i]} ${posx[$i]} ${posy[$i]}"
done
commands="$commands windowraise $wid"
echo "$commands" | xdotool -
}
for command in ${@} ; do
if [[ "$command" == "tile" ]] ; then
win_tile
elif [[ "$command" == "select" ]] ; then
win_select
elif [[ "$command" == "tiletwo" ]] ; then
win_tile_two
elif [[ "$command" == "tiletwol" ]] ; then
win_tile_two_left
elif [[ "$command" == "tiletwor" ]] ; then
win_tile_two_right
elif [[ "$command" == "stacktwo" ]] ; then
win_stack_two
elif [[ "$command" == "tilethree" ]] ; then
win_tile_three
elif [[ "$command" == "tilethreev" ]] ; then
win_tile_three_v
elif [[ "$command" == "cascade" ]] ; then
win_cascade
elif [[ "$command" == "showdesktop" ]] ; then
win_showdesktop
fi
done