This commit is contained in:
2026-01-26 17:03:18 +01:00
parent cd1b7cc874
commit 1fe5d48f1b
110 changed files with 12381 additions and 224 deletions

24
bin/about-mabox Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
OSCODE=$(grep CODENAME /etc/lsb-release |cut -d '=' -f2)
case "$LANG" in
pl*)
COMMENT="Lekki, szybki i funkcjonalny Linux z pulpitem na bazie Openbox"
;;
*)
COMMENT="Fast and Lightweight, ready to use Openbox Desktop"
;;
esac
yad --title="About Mabox" --window-icon=mbcc \
--about \
--pname="Mabox Linux" \
--pversion="$(lsb_release -rs) <i>${OSCODE}</i>" \
--image=mbcc \
--comments="${COMMENT}" \
--copyright="Copyright 2016-2025, Daniel Napora <danieln@maboxlinux.org>" \
--license=GPL3 \
--website="https://maboxlinux.org" \
--website-label=maboxlinux.org \
--authors="Daniel Napora <danieln@maboxlinux.org>"

187
bin/areaclick Executable file
View File

@@ -0,0 +1,187 @@
#!/bin/bash
# areaclick - root (desktop) areas/edges on click actions for Openbox
CFG_FILE="$HOME/.config/areaclick.conf"
makeconf() {
cat <<EOF > ${CFG_FILE}
# Sidearea width/height in pixels (set to 0 to disable side actions)
sidearea=100
# Commands
# Center area (or whole desktop if sidearea = 0)
cmd_center=show_desktop
# Sidearea commands:
cmd_topleft=show_desktop
cmd_top="jgdesktops -s"
cmd_topright="mb-music -s"
cmd_left="mb-jgtools places 2>/dev/null"
cmd_right="mb-jgtools right 2>/dev/null"
cmd_bottomleft="skippy-xd --expose"
cmd_bottom="skippy-xd --paging"
cmd_bottomright="mb-jgtools mblogout"
# Editor (for areaclick editconf command)
editor=geany
EOF
}
if [ ! -f ${CFG_FILE} ]; then
makeconf
fi
# read config variables from file
source <(grep = $CFG_FILE)
topleft() {
if [ -n "$cmd_topleft" ];then
bash <<< "$cmd_topleft"
else
left
fi
}
left(){
if [ -n "$cmd_left" ];then
bash <<< "$cmd_left"
else
center
fi
}
bottomleft() {
if [ -n "$cmd_bottomleft" ];then
bash <<< "$cmd_bottomleft"
else
left
fi
}
topright() {
if [ -n "$cmd_topright" ];then
bash <<< "$cmd_topright"
else
right
fi
}
right(){
if [ -n "$cmd_right" ];then
bash <<< "$cmd_right"
else
center
fi
}
bottomright() {
if [ -n "$cmd_bottomright" ];then
bash <<< "$cmd_bottomright"
else
right
fi
}
top(){
if [ -n "$cmd_top" ];then
bash <<< "$cmd_top"
else
center
fi
}
center(){
bash <<< "$cmd_center"
}
bottom() {
if [ -n "$cmd_bottom" ];then
bash <<< "$cmd_bottom"
else
center
fi
}
_leftside(){
if [ $Y -lt $((Y_OFF+sidearea)) ];then #topleft
topleft
elif [ $Y -gt $((Y_OFF+HEIGHT-sidearea)) ];then #bottomleft
bottomleft
else
left
fi
}
_rightside () {
if [ $Y -lt $((Y_OFF+sidearea)) ];then #topright
topright
elif [ $Y -gt $((Y_OFF+HEIGHT-sidearea)) ];then #bottomright
bottomright
else
right
fi
}
_middle () {
if [ $Y -lt $((Y_OFF+sidearea)) ];then #top
top
elif [ $Y -gt $((Y_OFF+HEIGHT-sidearea)) ];then #bottom
bottom
else
center
fi
}
_main() {
# Get mouse location
eval $(xdotool getmouselocation --shell)
# get monitor width,height and x,y-offset on current monitor (the one where pointer is)
while read -r line; do
info=$(echo $line | awk '{print $3}')
if [[ $info == primary ]]; then
info=$(echo $line | awk '{print $4}')
fi
read WIDTH HEIGHT X_OFF Y_OFF <<< $(echo $info | awk -F[x+] '{print $1, $2, $3, $4}')
if (( X >= X_OFF && X <= WIDTH + X_OFF )); then
break
fi
done < <(xrandr | grep " connected")
if [ $X -lt $((X_OFF+sidearea)) ];then
_leftside
elif [ $X -gt $((X_OFF+WIDTH-sidearea)) ];then
_rightside
else
_middle
fi
}
editconf(){
$editor $CFG_FILE
}
reset(){
makeconf
}
area() {
mb-setvar sidearea=${1} $CFG_FILE
}
case "$1" in
topleft) topleft;;
top) top;;
topright) topright;;
left) left;;
center) center;;
right) right;;
bottomleft) bottomleft;;
bottom) bottom;;
bottomright) bottomright;;
editconf) geany $CFG_FILE;;
reset) reset;;
area) area "$2";;
*) _main;;
esac

159
bin/bl-reload-gtk23 Executable file
View File

@@ -0,0 +1,159 @@
#!/usr/bin/env python3
#
# bl-reload-gtk23: Make GTK2/3 reload settings file changes
# Copyright (C) 2020 2ion <twoion@bunsenlabs.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from argparse import ArgumentParser, Namespace
import Xlib.display # type: ignore
import Xlib.protocol # type: ignore
import logging
import os
import psutil # type: ignore
import shutil
import signal
import subprocess
import sys
DESCRIPTION = ("""
After changing GTK2 and GTK3 configuration files, notify running GTK2 and GTK3
clients to apply those changes. The notification mechanism used by GTK3 requires
that xsettingsd is running. If it is installed and not running, the program will
launch it. Note that xsettingsd does not read settings from GTK3's settings.ini
- if information is changed, it must be changed in xsettingsd config files as well.
EXIT CODES:
0 - both gtk2 and gtk3 clients notified successfully
1 - failed to notify gtk2 clients
2 - failed to notify gtk3 clients
3 - failed to notify gtk2 and gtk3 clients
""")
LOG_FORMAT = "%(asctime)s %(levelname)s %(module)s %(funcName)s() : %(message)s"
def getopts() -> Namespace:
ap = ArgumentParser(description=DESCRIPTION)
ap.add_argument("-d", "--debug", action="store_true", default=False, help="print debug information")
ap.add_argument("-f", "--force", action="store_true", default=False, help="ignore all errors")
opts = ap.parse_args()
if opts.debug:
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
else:
logging.basicConfig(level=logging.WARN, format=LOG_FORMAT)
return opts
def sync_gtk2() -> None:
""" Tell GTK2 X11 clients to reload the GTK RC files and update their
appearance/settings if required. This implements this process without GTK/GDK
in order to be able to drop the dependency on the obsolete pygtk library.
GTK3/pygobject does not support GTK2.
This function will always fail on non-X11 platforms as the GTK2 client
notification mechanism is based on X.
This implementation is based on the following resources:
* From libgtk2 2.24.18:
* gdk_event_send_client_message_to_all_recurse()
* gdk_screen_broadcast_client_message()
* From kde-gtk-config https://github.com/KDE/kde-gtk-config/blob/a5d4ddb3b1a27ec2ee4e1b6957a98a57ad56d39c/gtkproxies/reload.c
"""
display = Xlib.display.Display(display=os.getenv("DISPLAY"))
wm_state_atom = display.intern_atom("WM_STATE", False)
gtkrc_atom = display.intern_atom("_GTK_READ_RCFILES", False)
def send_event(window) -> bool:
""" Send a _GTK_READ_RCFILES client message to the given X window.
Returns true unless an exception occurs. """
window.send_event(
Xlib.protocol.event.ClientMessage(
window = window,
client_type = gtkrc_atom,
data = (8, b"\0" * 20),
),
propagate = 0,
event_mask = 0
)
return True
def recurse_windows(window, parents) -> bool:
""" Given a X window, recurse over all its children and selectively
apply the send_event function to them. Returns true if an event got sent
to at least one window equal or below the given one. """
sent = False
wm_state = window.get_property(wm_state_atom, wm_state_atom, 0, 0)
name = window.get_wm_name()
level = len(parents)
if wm_state is not None:
sent = send_event(window)
else:
tree = window.query_tree()
for child in tree.children:
if not recurse_windows(child, parents + [window.id]) and level == 1:
sent = send_event(window)
logging.debug("%10s %s %s [%24s] [%s]",
hex(window.id),
"W" if not not wm_state else " ",
"S" if sent else " ",
name[:24] if name else "",
",".join(map(hex, parents)))
return sent
for sno in range(0, display.screen_count()):
screen = display.screen(sno)
recurse_windows(screen.root, [])
def sync_gtk3():
""" GTK3 applications can be notified of changes to their theming via
xsettingsd. This requires that the GTK3 theming information has been updated
in settings.ini as well as the gsettings schema, managed either by a
standalone xettingsd implementation or the gnome-settings-daemon. As for now,
we only support reloading `xsettingsd`: Send SIGHUP if we find it running, or
start it if it is installed and not running.
* https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
* https://github.com/KDE/kde-gtk-config/blob/a5d4ddb3b1a27ec2ee4e1b6957a98a57ad56d39c/kded/configeditor.cpp#L285
"""
found = False
for proc in psutil.process_iter():
if proc.name() == "xsettingsd":
proc.send_signal(signal.SIGHUP)
found = True
logging.debug("Found xsettingsd process and sent SIGHUP: PID %d", proc.pid)
break
if not found:
xsettingsd_binary = shutil.which("xsettingsd")
if xsettingsd_binary is not None:
proc = subprocess.Popen([xsettingsd_binary], cwd="/", start_new_session=True)
logging.debug("xsettingsd not running; started from %s; PID: %d", xsettingsd_binary, proc.pid)
else:
raise RuntimeError("xsettingsd not running and not in PATH, no settings changes propagated")
def main() -> int:
opts = getopts()
ret = 0
try:
sync_gtk2()
except Exception as err:
logging.warning("Failed to reload GTK2 settings: %s", err)
ret |= 1<<0
try:
sync_gtk3()
except Exception as err:
logging.warning("Failed to reload GTK3 settings: %s", err)
ret |= 1<<1
return 0 if opts.force else ret
if __name__ == "__main__":
sys.exit(main())

44
bin/compton_toggle Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
. "$HOME/.config/mabox/mabox.conf"
backend=${picom_renderer:-glx}
case "$LANG" in
pl*)
_DISABLED="Kompozytor Picom zastał WYŁĄCZONY"
_ENABLED="Kompozytor Picom został URUCHOMIONY"
_RENDERER="Sposób renderowania"
_WITHOUT="Bez pliku konfiguracyjnego (/dev/null)"
_MENU="Menu Konfiguracji..."
;;
*)
_DISABLED="Picom compositor DISABLED"
_ENABLED="Picom compositor ENABLED"
_RENDERER="Renderer backend"
_WITHOUT="Running without config file (/dev/null)"
_ERROR="Something went wrong"
_NOT_STARTED="Picom not started\nCheck your configuration"
_MENU="Configure Picom"
;;
esac
if [ $(pgrep -u $USER picom) ]; then
killall -u $USER picom
notify-send.sh --replace-file=/tmp/comptontgl -i compton -t 5000 "Compositor" "$_DISABLED" -o "$_MENU:jgpicom-pipe -s"
else
CONFIGFILE="$HOME/.config/picom.conf"
if [ -f "$CONFIGFILE" ];then
picom --backend "$backend" --config "$CONFIGFILE" &
sleep .25
if [ $(pgrep -u $USER picom) ]; then
notify-send.sh --replace-file=/tmp/comptontgl -i compton -t 8000 "$_ENABLED" "\n$_RENDERER: <b>$backend</b>" -o "$_MENU:jgpicom-pipe -s"
else
notify-send.sh --replace-file=/tmp/comptontgl -i error -t 8000 "$_ERROR" "\n$_NOT_STARTED\n$_RENDERER: <b>$backend</b>" -o "$_MENU:jgpicom-pipe -s"
fi
else
picom --backend "$backend" --config /dev/null &
sleep .25
notify-send.sh --replace-file=/tmp/comptontgl -i compton -t 8000 "$_ENABLED" "\n$_WITHOUT\n$_RENDERER <b>$backend</b>" -o "$_MENU:jgpicom-pipe -s"
fi
fi
exit

53
bin/conky_toggle Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
toggle(){
if pgrep -u $USER -f "conky -c" ;then
pkill -9 -u $USER conky
else
SESSIONFILE=$HOME/.config/conky/conky-sessionfile
while read -r line; do
if [[ $line == *conky* ]]; then
THIS_CONKY=$(echo "${line##+([[:space:]])}" | awk '{print $3}')
CONKYRC=${THIS_CONKY//\'/}
if ! pgrep -u $USER -f "${CONKYRC//\~/}"
then
conky -c "${CONKYRC//\~/$HOME}" &
else
pkill -u $USER -f "${CONKYRC//\~/}"
fi
fi
done < $SESSIONFILE
fi
exit 0
}
start_conky(){
SESSIONFILE=$HOME/.config/conky/conky-sessionfile
while read -r line; do
if [[ $line == *conky* ]]; then
THIS_CONKY=$(echo "${line##+([[:space:]])}" | awk '{print $3}')
CONKYRC=${THIS_CONKY//\'/}
if ! pgrep -u $USER -f "${CONKYRC//\~/}"
then
conky -c "${CONKYRC//\~/$HOME}" &
else
pkill -u $USER -f "${CONKYRC//\~/}"
fi
fi
done < $SESSIONFILE
}
stop_conky(){
if pgrep -u $USER -f "conky -c" ;then
pkill -9 -u $USER conky
fi
}
case "$1" in
start) start_conky;;
stop) stop_conky;;
*) toggle;;
esac

120
bin/cortilectl Executable file
View File

@@ -0,0 +1,120 @@
#!/bin/bash
# cortilectl - helper script for cortile tiling manager
# Cortile config file
CONFFILE="$HOME/.config/cortile/config.toml"
IMG_DIR="$HOME/.config/cortile/tint2-cortile"
start() {
echo "">/tmp/cortile.log
cortile -v &
}
stop() {
pkill cortile
}
editconf() {
xdg-open ${CONFFILE}
}
sendcmd(){
#notify-send.sh "$1" "aaa"
case "$1" in
proportion_increase) echo '{"Action":"proportion_increase"}' | nc -U /tmp/cortile.sock.in &2>/dev/null;;
proportion_decrease) echo '{"Action":"proportion_decrease"}' | nc -U /tmp/cortile.sock.in &2>/dev/null;;
window_next) echo '{"Action":"window_next"}' | nc -U /tmp/cortile.sock.in &2>/dev/null;;
window_previous) echo '{"Action":"window_previous"}' | nc -U /tmp/cortile.sock.in &2>/dev/null;;
esac
}
is_tiled(){
grep workspace-$(xdotool get_desktop) /tmp/cortile.log |tail -n 1 |grep Tile >/dev/null
}
is_fullscreen(){
grep workspace-$(xdotool get_desktop) /tmp/cortile.log |tail -n 1 |grep fullscreen >/dev/null
}
get_current_layout(){
layout=$(grep workspace-$(xdotool get_desktop) /tmp/cortile.log |tail -n 1| cut -d' ' -f6)
case "$layout" in
vertical-right) echo ${IMG_DIR}/vertical-right.png;;
vertical-left) echo ${IMG_DIR}/vertical-left.png;;
horizontal-top) echo ${IMG_DIR}/horizontal-top.png;;
horizontal-bottom) echo ${IMG_DIR}/horizontal-bottom.png;;
fullscreen) echo ${IMG_DIR}/fullscreen.png;;
esac
}
main(){
if ! pgrep -x cortile >/dev/null ;then exit 0;fi
if is_tiled ;then
get_current_layout
else
echo "${IMG_DIR}/untiled.png"
fi
}
left(){
if is_tiled ;then
if is_fullscreen ;then
#sendkey untile
echo "${IMG_DIR}/untiled.png"
echo '{"Action":"untile"}' | nc -U /tmp/cortile.sock.in &2>/dev/null
else
#sendkey layout_cycle
echo '{"Action":"cycle_next"}' | nc -U /tmp/cortile.sock.in &2>/dev/null
get_current_layout
fi
else
#sendkey tile
echo '{"Action":"tile"}' | nc -U /tmp/cortile.sock.in
echo '{"Action":"layout_vertical_left"}' | nc -U /tmp/cortile.sock.in
get_current_layout
fi
}
middle(){
echo '{"Action":"toggle"}' | nc -U /tmp/cortile.sock.in &2>/dev/null
if is_tiled ;then
get_current_layout
else
echo "${IMG_DIR}/untiled.png"
fi
}
right(){
: #menu
}
up(){
if is_tiled; then
if is_fullscreen ;then
sendcmd window_previous
else
sendcmd proportion_increase
fi
else
xdotool set_desktop --relative 1
fi
}
down(){
if is_tiled; then
if is_fullscreen ;then
sendcmd window_next
else
sendcmd proportion_decrease
fi
else
xdotool set_desktop --relative -- -1
fi
}
case "$1" in
start) start;;
stop) stop;;
editconf) editconf;;
left)left;;
right)right;;
middle)middle;;
up)up;;
down)down;;
*)main;;
esac

98
bin/deskgrid Executable file
View File

@@ -0,0 +1,98 @@
#!/bin/bash
### deskgrid - click on the window and select area to place it on the grid
# Works with active and inactive windows
# (C) Daniel Napora <napcok@gmail.com>, 2021-24
# https://maboxlinux.org
#
CONFIG_FILE="$HOME/.config/superclick.cfg"
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for clicksnap (mouse) action
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
COLUMNS=${columns:-12}
ROWS=${rows:-12}
#TITLEBAR_HEIGHT=${titlebar_height:-18}
case "$LANG" in
pl*)
TITLE1="DesktopGrid"
TEXT1="\n\nNarysuj myszą prostokąt na pulpicie aby ustalić nową pozycję i rozmiar dla okna.\nPodczas rysowania możesz wcisnąć Spację aby przesuwać zaznaczenie.\n"
DRAWGRID="Pokaż obrazek pomocniczy jako tło"
DISABLE_NOTIFICATIONS="Wyłącz podpowiedzi"
;;
*)
TITLE1="DesktopGrid"
TEXT1="\nDraw rectangle by mouse to set new window positon and size.\nWhile drawing you may hold Space key to move selection.\nNew window will be bigger than selection."
DRAWGRID="Show helper image as background"
DISABLE_NOTIFICATIONS="Disable this hint"
;;
esac
eval $(xdotool getmouselocation --shell)
# we have window id now as $WINDOW
HEX_ID=$(printf '0x%x\n' $WINDOW)
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
if xwininfo -id $CHILD_ID -wm |grep Dock ; then exit 0 ;fi # Ignore Dock eg. tint2
CHILD=$(printf %i $CHILD_ID)
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$(xprop -id $CHILD _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
xdotool windowminimize --sync $WINDOW
# Screen dimensions, margins and available size
SCREENSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $4}')
MARGINS=$(wmctrl -d |grep "*" | awk -F' ' '{print $8}')
AVAILSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $9}')
SCREEN_X="${SCREENSIZE%x*}"
SCREEN_Y="${SCREENSIZE#*x}"
AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${AVAILSIZE#*x}"
MARGIN_X="${MARGINS%,*}"
MARGIN_Y="${MARGINS#*,}"
#Show notify
if [ $notifications = true ]; then
notify-send.sh -t 20000 --icon=mbcc "$TITLE1" "$TEXT1" -o "$DRAWGRID:drawgrid" -o "$DISABLE_NOTIFICATIONS:mb-setvar notifications=false $CONFIG_FILE"
fi
# Take selection
slop=$(slop --highlight -b 3 --tolerance=0 --color=0.3,0.4,0.6,0.4 -f "%x %y %w %h") || exit 1
read -r X Y W H < <(echo $slop)
start_x="$(((X-MARGIN_X)/(AVAIL_X/COLUMNS)))"
start_y="$(((Y-MARGIN_Y)/(AVAIL_Y/ROWS)))"
end_x="$(((X-MARGIN_X+W)/(AVAIL_X/COLUMNS)))"
end_y="$(((Y-MARGIN_Y+H)/(AVAIL_Y/ROWS)))"
### Outer gap factor
if [[ $show_outer_gap = true ]]; then GF="1" ; else GF="0" ; fi
### SIZE and POS calculation
if [[ $start_x = "0" ]]; then GAP_X="$((GAP*GF))" ; else GAP_X=$((GAP/2)) ; fi
if [[ $start_y = "0" ]]; then GAP_Y="$((GAP*GF))" ; else GAP_Y=$((GAP/2)) ; fi
if [[ $end_x = $((COLUMNS-1)) ]]; then GAP_X_END="$((GAP/2))" ; else GAP_X_END=$((GAP/2)) ; fi
if [[ $end_y = $((ROWS-1)) ]]; then GAP_Y_END="$((GAP/2))" ; else GAP_Y_END=$((GAP/2)) ; fi
SIZE="$(((end_x-start_x+1)*(AVAIL_X/COLUMNS)-GAP_X/2-GAP_X_END-BORDERCOMP_X)) $(((end_y-start_y+1)*(AVAIL_Y/ROWS)-GAP_Y/2-GAP_Y_END-BORDERCOMP_Y))"
POSITION="$((start_x*AVAIL_X/COLUMNS+GAP_X/2+MARGIN_X)) $((start_y*AVAIL_Y/ROWS+GAP_Y/2+MARGIN_Y))"
xdotool windowsize $WINDOW $SIZE
xdotool windowmove $WINDOW $POSITION
xdotool windowmap $WINDOW

150
bin/deskmngr Executable file
View File

@@ -0,0 +1,150 @@
#!/bin/bash
# Copyright (C) Daniel Napora 2021-24 <napcok@gmail.com>
# https://maboxlinux.org
#: deskmngr - save all programs (windows) running on current desktop in session file.
#: With windows positions and state (decorated or not)
#: Usage:
#: -l|listsessions - list saved sessions
#: -s|save - save session from current desktop
#: -r|restore sesionfile desktop_ID - restore session from sessionfile on desktop
#:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SESSIONDIR="$HOME/.config/deskmngr/"
CONFIG_FILE="$SESSIONDIR/deskmngr.conf"
mkdir -p $SESSIONDIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
waitsec=1
EOF
fi
source <(grep = $CONFIG_FILE)
waittime=${waitsec:-1}
case "$LANG" in
pl*)
TITLE="Nie ma nic do zapisania"
TEXT="\nWygląda na to że nie ma otwartych okien na bieżącym pulpicie.\nUruchom jakieś programy i spróbuj ponownie.\n"
SAVE_AS="Zapisz sesję jako:"
SESSNAME="Nazwa sesji"
;;
*)
TITLE="Nothing to save"
TEXT="\nLooks like there are no windows to save on current desktop.\n Run some programs and try again.\n"
SAVE_AS="Save session as:"
SESSNAME="Session name"
;;
esac
savesession() {
curdesk=$(wmctrl -d | grep "*" | awk '{print $1}')
if [ $(wmctrl -l -p -G | awk -v c=$curdesk '$2 == c {print $2}' | wc -l) == "0" ];then notify-send -i dialog-warning "$TITLE" "$TEXT";exit 1;fi
if [ -n "$1" ]; then
filename="$1"
else
filename=$(yad --center --width=300 --title "$SAVE_AS" --entry --entry-label="$SESSNAME" --entry-text="$SESSNAME") || exit 1
fi
windows=()
wmctrl -l -p -G | {
while IFS= read -r line
do
read -r ID DESK PID x_offset y_offset width height rest< <(echo $line)
if [[ "$DESK" != "-1" ]]; then
if [[ "$DESK" == "$curdesk" ]]; then
cmdline=$(ps -fp $PID -o command=)
if [[ $cmdline != *quake-term* ]]; then
xwininfo -id "$ID" -wm | grep -q Undecorated && D="u" || D="d"
##
frameY=$(xwininfo -id "$ID" -stats | grep "Relative upper-left Y:" | cut -d: -f2)
frameX=$(xwininfo -id "$ID" -stats | grep "Relative upper-left X:" | cut -d: -f2)
windows+=("$D $width $height $((x_offset-frameX)) $((y_offset-2*frameY)) $cmdline")
fi
fi
fi
done
if [ ${#windows[@]} -eq 0 ]; then
notify-send -i dialog-warning "$TITLE" "$TEXT"
else
printf "%s\n" "${windows[@]}" > "$SESSIONDIR/${filename// /_}.desk"
# Serch replace
if command -v sd 1>/dev/null; then
sd -s "/usr/lib/chromium/chromium" "chromium --new-window" "$SESSIONDIR/${filename// /_}.desk"
sd -s "/usr/lib/firefox/firefox" "firefox --new-window" "$SESSIONDIR/${filename// /_}.desk"
sd -s "/usr/bin/python3 /usr/bin/terminator" "terminator" "$SESSIONDIR/${filename// /_}.desk"
sd -s "/usr/bin/python /usr/bin/terminator" "terminator" "$SESSIONDIR/${filename// /_}.desk"
sd -s "geany" "geany -i" "$SESSIONDIR/${filename// /_}.desk"
sd -s "cherrytree" "cherrytree --new-window" "$SESSIONDIR/${filename// /_}.desk"
sd -s "pcmanfm -d" "pcmanfm -n" "$SESSIONDIR/${filename// /_}.desk"
sd -s "Thunar --daemon" "thunar" "$SESSIONDIR/${filename// /_}.desk"
else
sed -i '/usr/lib/chromium/chromium,chromium --new-window,' "$SESSIONDIR/${filename// /_}.desk"
sed -i '/usr/lib/firefox/firefox,firefox --new-window,' "$SESSIONDIR/${filename// /_}.desk"
sed -i '/usr/bin/python3 /usr/bin/terminator,terminator,' "$SESSIONDIR/${filename// /_}.desk"
sed -i '/usr/bin/python /usr/bin/terminator,terminator,' "$SESSIONDIR/${filename// /_}.desk"
sed -i 'geany,geany -i,' "$SESSIONDIR/${filename// /_}.desk"
sed -i 'cherrytree,cherrytree --new-window,' "$SESSIONDIR/${filename// /_}.desk"
sed -i 'pcmanfm -d,pcmanfm -n,' "$SESSIONDIR/${filename// /_}.desk"
sed -i 'Thunar --daemon,thunar,' "$SESSIONDIR/${filename// /_}.desk"
fi
if command -v geany 1>/dev/null; then
geany "$SESSIONDIR/${filename// /_}.desk"
fi
fi
}
}
restoresession() {
sessfile="$1"
DESK="$2"
echo "$sessfile"
cat "$SESSIONDIR/$sessfile" | {
while IFS= read -r line
do
read -r D width height x y cmdline< <(echo $line)
wmctrl -s ${DESK}
${cmdline} > /dev/null 2>&1 &
# We need to wait for window to appear
sleep ${waittime}
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
if [[ "$D" = "u" ]]; then xdotool key super+b; fi
wmctrl -r :ACTIVE: -e 0,${x},${y},${width},${height}
done
}
}
overwrite() {
echo "Not implemented"
}
listsessions() {
ls -1 ${SESSIONDIR}| grep .desk
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
-s|save) savesession "$2";;
-r|restore) restoresession "$2" "$3";;
-o|overwrite) overwrite "$2" ;;
-l|list) listsessions ;;
-h|--help) usage;;
*) usage;;
esac
exit 0

58
bin/drawgrid Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
CONFIG_FILE="$HOME/.config/superclick.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for clicksnap (mouse) action
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
COLUMNS=${columns:-12}
ROWS=${rows:-12}
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${AVAILSIZE#*x}"
TILE_WIDTH="$((AVAIL_X/COLUMNS))"
TILE_HEIGHT="$((AVAIL_Y/ROWS))"
rectangles=""
row="0"
for row in $(seq 0 $((ROWS-1)));
do
for tile in $(seq 0 $((COLUMNS-1)));
do
rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) ";
done
done
name="text 24,96 DesktopGrid"
case $LANG in
pl*)
text="text 30,128 \"Ten obrazek ma pomóc ci zaprzyjaźnić się z siatką pulpitu DesktopGrid.\nDesktopGrid pozwala na dokładne ułożenie okien na pulpicie z opcjonalnym (konfigurowalnym) odstępem.\nJak to działa?\n1. Trzymając klawisze CTRL + SHIFT, kliknij wewnątrz okna które chcesz przemieścić. Okno zostanie zminimalizowane.\n2. Wyznacz myszą nową pozycję dla okna zaznaczając prostokąt\n3. Okno jest ustawiane wewnątrz siatki obliczonej na podstawie zaznaczenia.\n\nUżyj paska zadań aby schować/pokazać tło.\nAby wyłączyć tło: klik środkowym myszy na pasku zadań lub kliknięcie na obrazku i klawisz q\n\nSiatka: kolumny:$COLUMNS, wiersze:$ROWS, odstęp:$GAP\nRozmiar pojedyńczej komórki: $TILE_WIDTH x $TILE_HEIGHT\"";;
*)
text="text 30,128 \"This background image is here to help you get familiar with DesktopGrid.\nDesktopGrid allows you to accurately arrange windows on the desktop with optional gap (configurable).\nHow it's working?\n1. While holding down CTRL+ SHIFT keys, click inside the window you want to move. The window will be minimized.\n2. Use the mouse to mark a new position for the window by selecting the rectangle\n3. The window is positioned within the computed grid from the selection.\n\nCurrent Grid settings: $COLUMNS columns, $ROWS rows, gap:$GAP\nSingle tile size: $TILE_WIDTH x $TILE_HEIGHT\n\nUse mousewheel on taskbar to show/hide this background.\nTo close: middle click on taskbar or click here, then hit q key\""
;;
esac
magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \
-fill LavenderBlush3 \
-draw "$rectangles" \
-family 'Noto Sans' -style Normal +stroke -pointsize 14 -fill gray16 -draw "$text" \
-style Normal -weight Bold +stroke -pointsize 64 -fill orange3 -draw "$name" \
/tmp/grid.png
feh -N -x -g "$AVAILSIZE" --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 &
sleep 1
dghelper=$(wmctrl -l -p |grep "DrawGrid helper")
read -r A B C D< <(echo $dghelper)
wmctrl -i -r "$A" -b add,below

19
bin/killwindows Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
desktop() {
for n in $(wmctrl -l | awk -v d="$1" '$2 == d {print $1}')
do
wmctrl -i -c $n;
done
}
all() {
for n in $(wmctrl -l | awk $2 '!/-1/ {print $1}')
do
wmctrl -i -c $n;
done
}
case "$1" in
all) all;;
*) desktop "$1";;
esac

16
bin/lookat Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
# lookat(Desktop) - switch to desktop, if repeated switch back.
# Replacement for GoToDesktop Openbox action.
LD_FILE=~/.cache/.lastdesk
curdesk=$(wmctrl -d |grep '*' | awk '{print $1}')
todesk=$((${1} - 1))
if [[ "${curdesk}" == "${todesk}" ]];then
todesk=$(< "$LD_FILE")
else
echo "${curdesk}" > "$LD_FILE"
fi
wmctrl -s "${todesk}"

28
bin/mabox-langfiles Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Firstboot script
# Copy i18n files to ~ if available
# Check if Laptop|Notebook, otherwise disable power-manager
# Run only once invoked from openbox autostart
LNG=${LANG:0:2}
FILE="$HOME/.config/mabox/.lang"
if [ ! -f "$FILE" ]; then
if [ -d "/usr/share/mabox/lang/$LNG" ]; then
rsync -a /usr/share/mabox/lang/$LNG/ $HOME/
else
rsync -a /usr/share/mabox/lang/en/ $HOME/
fi
echo "selenized-black" > $HOME/.theme_history
# Power manager and tint2 native battery indicator only needed on Laptop/Netbook
TYPE=$(cat /sys/class/dmi/id/chassis_type)
case "$TYPE" in
8|9|10|14):;;
*)
mb-setvar Hidden=true "$HOME"/.config/autostart/xfce4-power-manager.desktop
# 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
touch $HOME/.config/mabox/.lang
fi

146
bin/mabox-logo Executable file
View File

@@ -0,0 +1,146 @@
#!/bin/bash
# mabox-logo - colorize Mabox logo, flat and 3d (cube). For use in Conky and panel (maybe)
. ~/.config/mabox/mabox.conf
mkdir -p "$HOME/.icons"
in_color=${logo_in_color:-#32B557}
in_opacity=${logo_in_opacity:-1.0}
out_color=${logo_out_color:-#FFFFFF}
out_opacity=${logo_out_opacity:-1.0}
LOGO_SQUARE=~/.icons/mabox-logo-square.svg
LOGO_3D=~/.icons/mabox-logo-3d.svg
LOGO_CIRCLE=~/.icons/mabox-logo-circle.svg
CONKYLOGO="$HOME/.config/conky/Mabox_logo_SVG_mbcolor.conkyrc"
mklogos(){
case "$1" in
--in-color|ic) in_color=${2};;
--out-color|oc) out_color=${2};;
--in-opacity|io) in_opacity=${2};;
--out-opacity|oo) out_opacity=${2};;
all)
in_color=${2}
in_opacity=${3}
out_color=${4}
out_opacity=${5}
;;
default)
in_color=#32B557
in_opacity=1
out_color=#F8F8FF
out_opacity=1
;;
esac
# square
cat <<EOF > ${LOGO_SQUARE}
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">
<path fill="${out_color}" fill-opacity="${out_opacity}" d="M0 0v256h256V0Zm16 16h224v224h-64V80h-16v160H96V80H80v160H16Z"/>
<path fill="${in_color}" fill-opacity="${in_opacity}" d="M80 240H16V16h224v224h-64V80h-16v160H96V80H80z"/>
</svg>
EOF
[[ ! -f "$HOME/.icons/mabox-logo-square-default.svg" ]] && cp "${LOGO_SQUARE}" "$HOME/.icons/mabox-logo-square-default.svg"
# 3D cube
cat <<EOF > ${LOGO_3D}
<svg xmlns="http://www.w3.org/2000/svg" width="1350" height="1350">
<path fill="${out_color}" fill-opacity="${out_opacity}" d="m675.469 35.245-581.09 189.03 573.45 260.3 592.67-257.6Zm-213.776 133.16 426.42 8.963 18.258 174.98-474.193-.484zm12.086 12.408-22.95 159.87 438.91.56-16.76-153.299zm21.08 11.274 358.641 4.838 13.082 132.39-105.23-.058-3.8-99.654-31.413-.43 2.537 99.586-105.367-.024 4.232-99.35-30.318.237-9.194 99.297-113.021.037zM65.098 253.454s43.103 463.121 65.154 694.621c175.89 115.17 351.351 231.05 526.951 346.68l-8.725-774.42c-3.242-2.767-582.7-267.85-583.38-266.88Zm1215.804 5.781c0-.03-588.8 263.04-588.8 263.04s-2.279 771.42.445 772.48l523.742-344.43ZM101.086 323.19l503.76 235.5s4.76 663.97 4.056 663.58l-134.884-88.175s-12.32-302.85-17.327-453.86l-39.154-17.644 13.867 443.039c-1.841-.542-123.63-79.893-123.63-79.893l-28.112-427.64-31.494-14.84 23.963 415.01c.133 2.314-112.08-69.5-112.15-70.137zm1141.713 3.334s-33.266 401.952-51.188 602.782c-39.452 21.937-116.5 70.802-116.5 70.802l24.7-426.73-33.282 17.209s-18.493 291.631-28.556 437.361l-125.27 76.008 14.895-440.77-38.659 20.077-17.689 451.68-140.31 87.831c-1.678-139.65 9.001-663.87 9.001-663.87l-.004-.009z"/>
<path fill="${in_color}" fill-opacity="${in_opacity}" d="M122.026 956.98C105.255 801.33 102.813 778.14 50 228.92L676.71 22.64 1300 225.42l-69.336 733.18-557.89 368.76zm526.96-437.21c-3.242-2.767-582.7-267.85-583.38-266.88 0 0 43.103 463.12 65.154 694.62 175.89 115.17 351.35 231.05 526.95 346.68zm-174.46 613.76s-12.32-302.85-17.326-453.86l-39.155-17.644 13.867 443.04c-1.842-.541-123.63-79.894-123.63-79.894l-28.113-427.64-31.494-14.84 23.964 415.01c.134 2.314-112.08-69.499-112.15-70.137l-58.895-604.94 503.76 235.5s4.758 663.97 4.055 663.58zm742.27-183.77 64.614-691.09c0-.03-588.8 263.04-588.8 263.04s-2.28 771.42.444 772.48zm-476.35-391.43 502.86-232.37s-33.266 401.95-51.188 602.78c-39.452 21.937-116.5 70.803-116.5 70.803l24.7-426.73-33.281 17.21s-18.494 291.63-28.557 437.36l-125.27 76.008 14.896-440.77-38.658 20.077-17.691 451.68-140.31 87.831c-1.677-139.65 9.002-663.87 9.002-663.87zm520.56-331.92L675.976 34.68 94.886 223.71l573.45 260.3zM432.686 351.3l29.515-183.46 426.42 8.963 18.257 174.98zm440.8-163.92-399.2-7.131-22.951 159.87 438.91.559zm-249.67 140.79 4.232-99.35-30.318.238-9.194 99.296-113.02.038 19.851-136.87 358.64 4.838 13.082 132.39-105.23-.057-3.798-99.655-31.414-.43 2.536 99.585z"/>
</svg>
EOF
[[ ! -f "$HOME/.icons/mabox-logo-3d-default.svg" ]] && cp "${LOGO_3D}" "$HOME/.icons/mabox-logo-3d-default.svg"
## circle
cat <<EOF > ${LOGO_CIRCLE}
<svg width="512" height="512" viewBox="0 0 135.467 135.467">
<path fill="${in_color}" fill-opacity="${in_opacity}" d="M67.733.927A66.806 66.806 0 0 0 .927 67.733a66.806 66.806 0 0 0 66.806 66.807 66.806 66.806 0 0 0 66.807-66.807A66.806 66.806 0 0 0 67.733.927Zm0 12.282a54.524 54.524 0 0 1 54.525 54.524 54.524 54.524 0 0 1-54.525 54.525A54.524 54.524 0 0 1 13.21 67.733 54.524 54.524 0 0 1 67.733 13.21ZM38.1 38.1v59.267h16.933V55.033h4.234v42.334H76.2V55.033h4.233v42.334h16.934V38.1Z"/>
<path fill="${out_color}" fill-opacity="${out_opacity}" d="M67.733 13.209A54.524 54.524 0 0 0 13.21 67.733a54.524 54.524 0 0 0 54.524 54.525 54.524 54.524 0 0 0 54.525-54.525A54.524 54.524 0 0 0 67.733 13.21ZM38.1 38.1h59.267v59.267H80.433V55.033H76.2v42.334H59.267V55.033h-4.234v42.334H38.1Z"/>
</svg>
EOF
[[ ! -f "$HOME/.icons/mabox-logo-circle-default.svg" ]] && cp "${LOGO_CIRCLE}" "$HOME/.icons/mabox-logo-circle-default.svg"
mb-setvar logo_in_color=$in_color
mb-setvar logo_out_color=$out_color
mb-setvar logo_in_opacity=$in_opacity
mb-setvar logo_out_opacity=$out_opacity
}
mkconky() {
cat << 'EOF' > ${CONKYLOGO}
conky.config = {
-- WINDOW
own_window = true,
own_window_type = 'desktop',
own_window_transparent = true,
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager,sticky',
own_window_class = 'Conky-nobg',
own_window_title = 'Mabox Logo SVG',
alignment = 'middle_middle',
gap_x = 0,
gap_y = 0,
minimum_height = 48,
minimum_width = 48,
template0 = [[~/.icons/mabox-logo-square.svg]],
template1 = [[48x48]],
draw_borders = false,
border_inner_margin = 0,
border_outer_margin = 0,
border_width = 0,
background = true,
no_buffers = true,
imlib_cache_size = 0,
double_buffer = true,
update_interval = 0.6,
};
conky.text = [[
${image ${template0} -s ${template1}}
]];
EOF
}
mkmenu() {
case "$LANG" in
pl*)
cp /usr/share/mabox/lang/pl/.config/conky/menuscripts/Mabox_logo_SVG.csv ~/.config/conky/menuscripts/Mabox_logo_SVG.csv
;;
*)
cp /usr/share/mabox/lang/en/.config/conky/menuscripts/Mabox_logo_SVG.csv ~/.config/conky/menuscripts/Mabox_logo_SVG.csv
;;
esac
}
size () {
sd "minimum_height.*$" "minimum_height = ${1}," ${CONKYLOGO}
sd "minimum_width.*$" "minimum_width = ${1}," ${CONKYLOGO}
sd "template1 =.*$" "template1 = [[${1}x${1}]]," ${CONKYLOGO}
}
type () {
case "$1" in
square)
sd "template0 =.*$" "template0 = [[~/.icons/mabox-logo-square.svg]]," ${CONKYLOGO}
;;
3d)
sd "template0 =.*$" "template0 = [[~/.icons/mabox-logo-3d.svg]]," ${CONKYLOGO}
;;
circle)
sd "template0 =.*$" "template0 = [[~/.icons/mabox-logo-circle.svg]]," ${CONKYLOGO}
;;
esac
}
init(){
mklogos default
mkconky
mkmenu
}
revcolors () {
mklogos all ${logo_out_color} ${logo_out_opacity} ${logo_in_color} ${logo_in_opacity}
}
case "$1" in
init) init;;
size)size "$2";;
type)type "$2";;
revcolors)revcolors;;
*)mklogos "$1" "$2" "$3" "$4" "$5";;
esac

131
bin/mabox-obstart Executable file
View File

@@ -0,0 +1,131 @@
#!/usr/bin/env bash
#
#
virtualboxes() {
case $LANG in
pl*)
VBOXGUI="VirtualBox GUI"
VBOXES="Maszyny wirtualne"
REFRESH="Odśwież listę"
;;
es*)
VBOXGUI="Interfaz VirtualBox"
VBOXES="Virtual Machines"
REFRESH="Refrescar lista"
;;
*)
VBOXGUI="VirtualBox GUI"
VBOXES="Virtual Machines"
REFRESH="Refresh list"
;;
esac
if [[ -x "$(command -v VBoxManage)" ]]; then
{
printf "%b\n" "^sep($VBOXES)"
printf "%b\n" "$VBOXGUI,virtualbox"
printf "%b\n" "^sep()"
}> $HOME/.config/mabox/vboxes.csv
VBoxManage list -s vms | cut -f 2 -d "\"" | sort -f | while read vm
do
printf "%s\n" "$vm,vboxmanage startvm \"${vm}\"" >>$HOME/.config/mabox/vboxes.csv
done
printf "%s\n%s\n" "^sep()" "$REFRESH,/usr/bin/mabox-obstart virtualboxes" >>$HOME/.config/mabox/vboxes.csv
fi
}
phwmon() {
#kill phwmon.py if running
if phwmonpid=$(pgrep -f phwmon.py); then
kill $phwmonpid
sleep 1
fi
. $HOME/.config/mabox/mabox.conf
if [ $phwmon_monitor = true ];then
#Set config variables if not set or empty; ":" means do nothing
[[ -v phwmon_monitor ]] && : || mb-setvar phwmon_monitor=true
[[ -v phwmon_cpu ]] && : || mb-setvar phwmon_cpu=true
[[ -v phwmon_mem ]] && :|| mb-setvar phwmon_mem=true
[[ -v phwmon_swap ]] && : || mb-setvar phwmon_swap=false
[[ -v phwmon_net ]] && : || mb-setvar phwmon_net=true
[[ -v phwmon_io ]] && : || mb-setvar phwmon_io=false
[[ -v phwmon_bgcolor ]] && : || mb-setvar phwmon_bgcolor=#30303080
[[ -v phwmon_alertcolor ]] && : || mb-setvar phwmon_alertcolor=#ff0000
[[ -v phwmon_cpucolor ]] && : || mb-setvar phwmon_cpucolor=#70b433
[[ -v phwmon_memcolor ]] && :|| mb-setvar phwmon_memcolor=#efc541
[[ -v phwmon_swapcolor ]] && : || mb-setvar phwmon_swapcolor=#ff81ca
[[ -v phwmon_netcolor ]] && : || mb-setvar phwmon_netcolor=#368aeb
[[ -v phwmon_iocolor ]] && : || mb-setvar phwmon_iocolor=#ff5e56
[[ -v phwmon_iconsize ]] && : || mb-setvar phwmon_iconsize=32
bg="--bg=${phwmon_bgcolor:-#30303080}"
fg_alert="--fg_alert=${phwmon_alertcolor:-#ff0000}"
fg_cpu="--fg_cpu=${phwmon_cpucolor:-#70b433}"
fg_mem="--fg_mem=${phwmon_memcolor:-#efc541}"
fg_swap="--fg_swap=${phwmon_swapcolor:-#ff81ca}"
fg_net="--fg_net=${phwmon_netcolor:-#368aeb}"
fg_io="--fg_io=${phwmon_iocolor:-#ff5e56}"
iconsize="--size=${phwmon_iconsize:-32}"
[[ $phwmon_cpu = true ]] && cpu="--cpu" || cpu=""
[[ $phwmon_mem = true ]] && mem="--mem" || mem=""
[[ $phwmon_swap = true ]] && swap="--swap" || swap=""
[[ $phwmon_net = true ]] && net="--net" || net=""
[[ $phwmon_io = true ]] && io="--io" || io=""
#phwmon.py ${cpu} ${mem} ${swap} ${net} ${io} --task_manager lxtask
phwmon.py ${cpu} ${mem} ${swap} ${net} ${io} ${bg} ${fg_alert} ${fg_cpu} ${fg_mem} ${fg_swap} ${fg_net} ${fg_io} ${iconsize} --task_manager="lxtask" 2>/dev/null &
fi
}
checkautostart () {
# Copy only new files from /etc/xdg/autostart/
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
rsync -aq --ignore-existing /etc/xdg/autostart/ $config_dir/autostart
}
startopenbox() {
checkautostart
# Run mwelcome if not disaled
[ ! -f "$HOME/.config/mabox/.mwelcome" ] && mwelcome &
# [ -f "$HOME/.config/wpg/.mabox-init" ] && wpg-mabox-init &
# rename old wrappers, they now in /usr/local/bin
#wrappers=(nitrogen i3lock xrandr lxappearance skippy-xd-fix)
#for wrapper in "${wrappers[@]}"
#do
#[[ -f "$HOME/.local/bin/${wrapper}" ]] && mv "$HOME/.local/bin/${wrapper}" "$HOME/.local/bin/${wrapper}.old"
#done
. $HOME/.config/mabox/mabox.conf
#Set config variables if not set or empty; ":" means do nothing
# NEW CONFIG VARIABLES - SET defaults at openbox start
[[ -v places_tint2pipe ]] && : || mb-setvar places_tint2pipe=true
[[ -v places_quicknav ]] && : || mb-setvar places_quicknav=true
[[ -v places_bookmarks ]] && : || mb-setvar places_bookmarks=true
[[ -v places_vboxes ]] && : || mb-setvar places_vboxes=false
[[ -v menu_sep_font_family ]] && : || mb-setvar "menu_sep_font_family='Noto Sans Bold'"
[[ -v menu_sep_font_size ]] && : || mb-setvar menu_sep_font_size=10
[[ -v item_height_factor ]] && : || mb-setvar item_height_factor=200
virtualboxes
if command -v phwmon.py &>/dev/null; then
phwmon
fi
}
case "$1" in
startopenbox) startopenbox;;
checkautostart) checkautostart;;
virtualboxes) virtualboxes;;
phwmon) phwmon;;
*)
echo -e "Usage $(basename "$0") startopenbox|checkautostart|virtualboxes|phwmon" >&2
exit 1
;;
esac
exit 0

45
bin/mabox-terminal Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# Author: Daniel Napora <napcok@gmail.com> 2018-2024
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. C-~ or F12.
# Depenging on actual state it will start, show or hide terminal window.
GEOMETRY_FILE="$HOME/.config/mabox/.quake-term"
NAME="Quake Term"
__run() {
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
if [ -z "${ID}" ]; then
if [ -f "$GEOMETRY_FILE" ]; then
POS=$(head -n 1 $GEOMETRY_FILE)
terminator -T "${NAME}" -b --geometry "$POS" -i utilities-terminal
else
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
LEFT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/8]
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
WIDTH=$[${LEFT}*6]
terminator -T "${NAME}" -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -i utilities-terminal
fi
else
ID_DEC=$((${ID}))
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
xdotool windowminimize ${ID_DEC}
else
xdotool windowactivate ${ID_DEC}
fi
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
fi
}
__reset() {
rm "$GEOMETRY_FILE"
}
case "$1" in
reset) __reset;;
*) __run;;
esac
exit 0

17
bin/mb-brightness Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
## mb-brightness - control brightness on Mabox
CARD=$(ls /sys/class/backlight | head -n 1)
inc() {
[[ "$CARD" == *"intel_"* ]] && xbacklight -inc 10 || light -A 5
}
dec() {
[[ "$CARD" == *"intel_"* ]] && xbacklight -dec 10 || light -U 5
}
case "$1" in
inc)inc;;
dec)dec;;
esac

418
bin/mb-canvas Executable file
View File

@@ -0,0 +1,418 @@
#!/bin/bash
## An Imagemagick Script To Generate Wallpapers.
## Based on https://github.com/adi1090x/canvas by Aditya Shakya (adi1090x)
## Modified by Daniel Napora for Mabox Linux to run from menu
CONFIG_DIR="$HOME/.config/mabox/tools/"
CONFIG_FILE="$CONFIG_DIR/mb-canvas.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Imagetype extension avif or png
# avif (recommended) faster and much smaller size
extenstion=avif
# Show preview window, and then decide to set as wallpaper or not
# if no denerated wallpaper will be applied immadietely
# yes (recommended) or no
show_preview=yes
EOF
fi
source <(grep = $CONFIG_FILE)
extension=${extension:-avif}
show_preview=${show_preview:-yes}
case $LANG in
pl*)
_IMWG="Generator Tapet"
_PICKCOLOR="Pobierz kolor z ekranu"
_PICKCOLORS="Pobierz kolory z ekranu"
_PICKEDCOLOR="Pobrany kolor"
_PICKNEXT="Pobierz nastepny"
_PICKEDALL="Generuję tapetę..."
_SETASWP="Ustawić jako tapetę?"
_YES="Tak"
_NO="Nie"
;;
*)
_IMWG="ImageMagick Wallpaper Generator"
_PICKCOLOR="Pick color from screen"
_PICKCOLORS="Pick colors from screen"
_PICKEDCOLOR="Picked color"
_PICKNEXT="Please pick next..."
_PICKEDALL="Generating Wallpaper..."
_SETASWP="Set as Wallpaper?"
_YES="Yes"
_NO="No"
;;
esac
DIR="$(xdg-user-dir PICTURES)/imagick"
size="$(xrandr --current | grep '*' | uniq | awk '{print $1}')"
name="imagick_$(date +%Y-%m-%d_%I-%M-%S).${extension}"
#SETTER="feh --bg-scale";
SETTER="nitrogen --set-scaled --save"
#picker_app="gpick -s -o --no-newline"
picker_app="gpick -pso 2>/dev/null"
if [[ ! -d "$DIR" ]]; then
mkdir -p "$DIR"
fi
set_bg() {
if [[ "$show_preview" == "yes" ]];then
X="${size%x*}"
Y="${size#*x}"
P_X=$((X/4))
P_Y=$((Y/4+30))
yad --title="$_SETASWP" --window-icon=mbcc --borders=0 --geometry="${P_X}x${P_Y}+200+30" \
--picture --size=fit --filename="$DIR/$name" \
--button="$_NO":1 --button="$_YES":2 \
ODP="$?"
if [[ "$ODP" -eq "1" ]]; then
rm "$DIR/$name" && exit 0
fi
if [[ "$ODP" -eq "2" ]]; then
$SETTER "$DIR/$name" && exit 0
fi
else
$SETTER "$DIR/$name"
fi
}
## Pick the colors
color_picker() {
if [[ "$SOLID" == "true" ]]; then
notify-send.sh "$_IMWG" "$_PICKCOLOR" -i mbcc --expire-time=12000
color=$($picker_app)
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]] || "$PLASMA" == "true" ]]; then
notify-send.sh "$_IMWG" "$_PICKCOLORS: 2" -i mbcc --expire-time=12000
color1=$($picker_app)
FNAME="/tmp/${color1:1:6}.png"
convert -size 100x100 xc:"$color1" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 1" "$color1\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color2=$($picker_app)
FNAME="/tmp/${color2:1:6}.png"
convert -size 100x100 xc:"$color2" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 2" "$color1\n $_PICKEDALL" --icon="$FNAME" --expire-time=12000
color="$color1-$color2"
elif [[ "$BGRADIENT" == "true" ]]; then
notify-send.sh "$_IMWG" "$_PICKCOLORS: 4" -i mbcc --expire-time=12000
color1=$($picker_app)
FNAME="/tmp/${color1:1:6}.png"
convert -size 100x100 xc:"$color1" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 1" "$color1\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color2=$($picker_app)
FNAME="/tmp/${color2:1:6}.png"
convert -size 100x100 xc:"$color2" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 2" "$color2\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color3=$($picker_app)
FNAME="/tmp/${color3:1:6}.png"
convert -size 100x100 xc:"$color3" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 3" "$color3\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color4=$($picker_app)
FNAME="/tmp/${color4:1:6}.png"
convert -size 100x100 xc:"$color4" "$FNAME"
notify-send.sh "$_PICKEDCOLOR 4" "$color4\n $_PICKEDALL" --icon="$FNAME" --expire-time=12000
fi
}
## Get colors
get_color() {
while true; do
color_picker
break
done
}
## Generate a solid color wallpaper
solid() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
else
get_color
fi
magick convert -size "$size" canvas:"$color" "$DIR/$name"
set_bg
}
## Generate a linear gradient wallpaper
linear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
get_random_number "360"
angle="$RNUM"
else
get_color
angle=$(yad --center --window-icon=mbcc --title="Linear gradient" --text="\tRotation angle (default is 0):" --width=400 --scale --min-value=0 --max-value=360 --step=45 --enforce-step --inc-buttons)
fi
name="linear_$name"
magick convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
set_bg
}
## Generate a radial gradient wallpaper
radial_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "360"
angle="$RNUM"
getRandomShape
shape="$RSHAPE"
else
get_color
shape=$(yad --center --window-icon=mbcc --title='Choose Shape' --width=180 --height=145 --button=Ok:0 --list --no-headers --column=Shape diagonal ellipse maximum minimum | tr -d '|')
angle=$(yad --center --window-icon=mbcc --title="Radial gradient" --text="\tRotation angle:" --width=400 --scale --min-value=0 --max-value=360 --step=45 --enforce-step --inc-buttons)
fi
name="radial_$name"
magick convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
set_bg
}
## Generate a twisted gradient wallpaper
twisted_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "500"
twist="$RNUM"
else
get_color
twist=$(yad --center --window-icon=mbcc --title="Radial gradient" --text="\tTwisting amount (default is 150):" --width=400 --scale --value=150 --min-value=0 --max-value=500 --step=20 --inc-buttons)
fi
name="twisted_$name"
magick convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
set_bg
}
## Generate a 4 point gradient wallpaper
bilinear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color2="$RCOLOR"
get_random_color
color3="$RCOLOR"
get_random_color
color4="$RCOLOR"
get_random_number "2"
if [[ "$RNUM" == "1" ]]; then
answer="Smooth"
else
answer="Regular"
fi
else
get_color
answer=$(yad --title='Choose Style' --width=220 --height=120 --button=Ok:0 --list --no-headers --column=Style Smooth Regular | tr -d '|')
fi
name="bilinear_$name"
if [[ $answer == "Smooth" ]] || [[ $answer == "S" ]]; then
magick convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -size "$size" xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' "$DIR/$name"
else
magick convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
fi
set_bg
}
## Generate a plasma wallpaper
plasma() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "3"
if [[ "$RNUM" == "1" ]]; then
answer="Random"
elif [[ "$RNUM" == "2" ]]; then
answer="Twisted"
get_random_number "500"
twist="$RNUM"
else
answer="c"
get_random_color
color="$RCOLOR"
fi
else
answer=$(yad --title='Choose Style' --width=190 --height=150 --button=Ok:0 --list --no-headers --column=Style Random Twisted 'Custom colors' | tr -d '|')
fi
name="plasma_$name"
if [[ $answer == "r" ]] || [[ $answer == "Random" ]]; then
convert -size "$size" plasma: "$DIR/$name"
elif [[ $answer == "t" ]] || [[ $answer == "Twisted" ]]; then
if [[ "$RANDOMIZE" != "true" ]]; then
twist=$(yad --center --window-icon=mbcc --title="Plasma" --text="\tTwisting amount (default is 150):" --width=400 --scale --value=150 --min-value=0 --max-value=500 --step=20 --inc-buttons)
fi
magick convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
else
if [[ "$RANDOMIZE" != "true" ]]; then
get_color
fi
magick convert -size "$size" plasma:"$color" "$DIR/$name"
fi
set_bg
}
## Generate a random, multi-colored blurred/gradient wallpaper
blurred_noise() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "30"
blur="$RNUM"
else
{ echo; read -p ${ORANGE}"Enter the blur strength (maximum 30): "${BLUE} blur; }
fi
magick convert -size "100x56" xc: +noise Random "/tmp/noise.png"
magick convert "/tmp/noise.png" -virtual-pixel tile -blur 0x"${blur:-14}" -auto-level -resize "$size" "$DIR/$name"
set_bg
}
## Generate random number lower than given parameter
get_random_number() {
RNUM=$(( ($RANDOM % $1) + 1 ))
}
## Generate random color
get_random_color() {
RCOLOR="#"
for i in 1 2 3 4 5 6
do
get_random_number "16"
case $RNUM in
"1") NEXTDIGIT="1";;
"2") NEXTDIGIT="2";;
"3") NEXTDIGIT="3";;
"4") NEXTDIGIT="4";;
"5") NEXTDIGIT="5";;
"6") NEXTDIGIT="6";;
"7") NEXTDIGIT="7";;
"8") NEXTDIGIT="8";;
"9") NEXTDIGIT="9";;
"10") NEXTDIGIT="A";;
"11") NEXTDIGIT="B";;
"12") NEXTDIGIT="C";;
"13") NEXTDIGIT="D";;
"14") NEXTDIGIT="E";;
"15") NEXTDIGIT="F";;
"16") NEXTDIGIT="0";;
esac
RCOLOR="$RCOLOR$NEXTDIGIT"
done
}
## Generate random shape option
getRandomShape() {
get_random_number "4"
case $RNUM in
"1") RSHAPE="diagonal";;
"2") RSHAPE="ellipse";;
"3") RSHAPE="maximum";;
"4") RSHAPE="minimum";;
esac
}
## Generate random wallpaper
randomize() {
get_random_number "7"
case $RNUM in
"1") solid;;
"2") linear_gradient;;
"3") radial_gradient;;
"4") twisted_gradient;;
"5") bilinear_gradient;;
"6") plasma;;
"7") blurred_noise;;
esac
}
## Parse the arguments
options=$(getopt -o S:,s,l,r,t,b,p,B,h,a,R --long size:,solid,linear,radial,twisted,bilinear,plasma,blurred,help,autobg,randomize -- "$@")
eval set -- "$options"
while true; do
case "$1" in
-S|--size)
shift;
size=$1
;;
-s|--solid)
SOLID="true"
COLOR=$1
;;
-l|--linear)
GRADIENT="true"
;;
-r|--radial)
RGRADIENT="true"
;;
-t|--twisted)
TGRADIENT="true"
;;
-b|--bilinear)
BGRADIENT="true"
;;
-p|--plasma)
PLASMA="true"
;;
-B|--blurred)
NOISE="true"
;;
-a|--autobg)
AUTOBG="true"
;;
-R|--randomize)
RANDOMIZE="true"
;;
-h|--help)
usage
exit
;;
--)
shift
break
;;
esac
shift
done
## Main Execution
if [[ "$SOLID" == "true" ]]; then
solid
elif [[ "$GRADIENT" == "true" ]]; then
linear_gradient
elif [[ "$RGRADIENT" == "true" ]]; then
radial_gradient
elif [[ "$TGRADIENT" == "true" ]]; then
twisted_gradient
elif [[ "$BGRADIENT" == "true" ]]; then
bilinear_gradient
elif [[ "$PLASMA" == "true" ]]; then
plasma
elif [[ "$NOISE" == "true" ]]; then
blurred_noise
elif [[ "$RANDOMIZE" == "true" ]]; then
randomize
else
usage
fi

97
bin/mb-cli Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/bash
# mb-cli run some commands from launchers in terminal
OPT="--geometry=720x480"
case "$LANG" in
pl*)
_NOT_FOUND_TERMINATOR="Terminator nie został znaleziony!"
_DESC="Zainstaluj Terminatora, aby wykonać skrypt"
_INSTALL_TERMINATOR="Zainstaluj Terminatora"
;;
*)
_NOT_FOUND_TERMINATOR="Terminator not found!"
_DESC="To run script install Terminator first"
_INSTALL_TERMINATOR="Install Terminator"
;;
esac
if ! hash terminator &> /dev/null
then
notify-send.sh -i error "$_NOT_FOUND_TERMINATOR" "$_DESC" -o "$_INSTALL_TERMINATOR:pamac-installer terminator"
exit 1
fi
case "$LANG" in
pl*)
_UPDATE="Aktualizacja systemu"
_STATS="Statystyki pakietów"
_MIRRORS="Ranking mirrorów"
_PACCACHE="Czyszczenie cache pacman oraz yay (AUR)"
_BTOP="Btop - monitor zasobów"
_FINISHED="Zakończono! Wciśnij ENTER aby zamknąć terminal"
;;
*)
_UPDATE="System update"
_STATS="Package statistics"
_MIRRORS="Mirror ranking"
_PACCACHE="Pacman and Yay (AUR) cache cleaning"
_BTOP="Btop - a monitor of resources"
_FINISHED=" FINISHED! Hit ENTER or close this window"
;;
esac
case "$1" in
update)
CMD="yay -Syu"
terminator "${OPT}" -T "$_UPDATE: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
tint2-send refresh-execp mb-status
;;
update-noaur)
CMD="yay -N -Syu"
terminator "${OPT}" -T "$_UPDATE: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
tint2-send refresh-execp mb-status
;;
pacupdate)
CMD="sudo pacman -Syu"
terminator "${OPT}" -T "$_UPDATE: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
tint2-send refresh-execp mb-status
;;
stats)
CMD="yay -Ps"
terminator "${OPT}" -T "$_STATS: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
mirrors)
CMD="sudo pacman-mirrors -f5"
terminator "${OPT}" -T "$_MIRRORS: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
mirrors_all)
CMD="sudo pacman-mirrors -i -c all"
terminator "${OPT}" -T "$_MIRRORS: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
mirrors_geo)
CMD="sudo pacman-mirrors -i --geoip"
terminator "${OPT}" -T "$_MIRRORS: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
paccache_clean)
CMD="yay -Scc"
terminator "${OPT}" -T "$_PACCACHE: ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
vacuum)
case "$2" in
1d) CMD="sudo journalctl --vacuum-time=1d";;
7d) CMD="sudo journalctl --vacuum-time=7d";;
200M) CMD="sudo journalctl --vacuum-size=200M";;
500M) CMD="sudo journalctl --vacuum-size=500M";;
esac
terminator "${OPT}" -T "_VACUUM_LOGS ($CMD)" -e "${CMD};read -p \"${_FINISHED}\""
;;
pkginfo)
terminator "${OPT}" -T "PKG info: ${2} (yay -Qi ${2})" -e "yay -Qi ${2};/bin/bash"
;;
btop)
terminator "${OPT}" -T "$_BTOP" -e "btop"
;;
*):;;
esac

371
bin/mb-conky-manager Executable file
View File

@@ -0,0 +1,371 @@
#!/bin/bash
#
# bl-conky-manager: BunsenLabs Conky selection and switcher script
# Copyright (C) 2015-2019 damo <damo@bunsenlabs.org>
# 2019-2020 John Crawley <john@bunsenlabs.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
# Beta tested and stamped "zen" by <Sector11>
#
# Adapted, rapackaged for Mabox by napcok <napcok@gmail.com>, August 2020
#
########################################################################
#
# Conkys must be in $CONKYPATH
# The name must end with "conky", conkyrc or be "*conky*.conf"
#
# When the dialog opens, any running conkys will be checkmarked.
#
# Click "OK" and all running conkys are stopped, and all checkmarked
# conkys are started
#
# To stop a conky just uncheck it, and "OK"
#
# Running conkys are saved to a session file, and can be run with
# the "bl-conky-session" script. To start the default conky session at
# login, add the following line to autostart:
#
# mb-conky-session --autostart &
#
# Different saved-session files can be used by running the script with:
#
# mb-conky-manager -f /path/to/sessionfile &
# mb-conky-manager -z (opens gui entry dialog for filepath)
#
########################################################################
CONKYPATH="$HOME/.config/conky"
SESSIONFILE="$CONKYPATH/conky-sessionfile"
SESSIONS="$CONKYPATH/saved-sessions" # to be used by a pipemenu
CONKYDEFAULT="$CONKYPATH/conky.conf"
BLDEFAULT="$CONKYPATH/manjaro_JWM.conkyrc"
USAGE1='
USAGE: mb-conky-manager [OPTION]...FILES
With no command option the script runs the gui
-h,--help : The full USAGE help
-f,--file : FILEPATH : specify file to save session to
-z : Run gui filename entry dialog for new saved session
'
USAGE2='mb-conky-manager is a Conky selection and switcher script
which uses yad to generate a graphical user interface.
Usage: mb-conky-manager [OPTION]...FILES
With no command option the script runs the gui
Optional arguments:
-h,--help : This USAGE help
-f,--file : FILEPATH : specify file to save session to
-z : Run gui filename entry dialog for new saved session
When the dialog opens, any running conkys will be checkmarked.
Click "OK" and all running conkys are stopped, and all
checkmarked conkys are started.
To stop a conky just uncheck it, and click "OK"
Examples:
Save session to a new saved-session file with:
mb-conky-manager -f sessionfile-name
To start the default conky session at login, add the
following line to autostart:
mb-conky-session --autostart &
'
### DIALOG VARIABLES
case $LANG in
pl*)
TITLE="Menedżer Conky"
CONKY_SESSIONFILE="Plik sesji Conky"
FILENAME_IN_USE="Nazwa pliku już jest używana.\n\nNadpisać?"
SAVE_SESSION="Zapisz sesję Conky"
NEW_FILE="Nowy plik zapisanej sesji:"
FILE_TO_SAVE="Plik do zapisania w <b>$CONKYPATH/</b>\n\n"
SESS_SAVE="Wybierz pliki Conky, które mają być uruchomione.\nSesja zostanie zachowana w:\n <i>$SESSIONFILE</i>"
SELECT="Wybór:CHK"
CONF_FILE="Plik konfiguracyjny:TXT"
NOTHING_SELECTED="Nic nie wybrano.\n\nWyłączyć działające Conky\ni wyjść?"
OK="--button=OK:2"
APPLY="--button=Zastosuj:0"
CANCEL="--button=Anuluj:1"
CLOSE="--button=Zamknij:1"
;;
es*)
TITLE="Gestor de recuadro(s) Conky"
CONKY_SESSIONFILE="Sesión actual de archivo(s) Conky"
FILENAME_IN_USE="Renombrar archivo en ejecución\n\Sobreescribirlo ?"
SAVE_SESSION="Guardar la sesión actual de archivo(s) conky"
NEW_FILE="Abrir sesión(es) de archivo(s) guardada(s):"
FILE_TO_SAVE="el archivo será guardado en <b>$CONKYPATH/</b>\n\n"
SESS_SAVE="Elegir los archivos Conky, que desea ejecutar.\nEsta sesión será guardada en:\n <i>$SESSIONFILE</i>"
SELECT="Seleccionar:CHK"
CONF_FILE="Nombrar archivo Conky:TXT"
NOTHING_SELECTED="Ninguno seleccionado.\n\nterminar los archivos Conky en ejecución\ny salir ?"
OK="--button=Aceptar:2"
APPLY="--button=Aplicar:0"
CANCEL="--button=Cancelar:1"
CLOSE="--button=Cerrar:1"
;;
*)
TITLE="Conky Manager"
CONKY_SESSIONFILE="Conky sessionfile"
FILENAME_IN_USE="Filename already in use\n\nOverwrite it?"
SAVE_SESSION="Save Conky sessionfile"
NEW_FILE="New saved session file:"
FILE_TO_SAVE="File to be saved in <b>$CONKYPATH/</b>\n\n"
SESS_SAVE="Choose Conky file, which you like to start.\nSession will be saved to:\n <i>$SESSIONFILE</i>"
SELECT="Select:CHK"
CONF_FILE="Conky Name:TXT"
NOTHING_SELECTED="Nothing chosen.\n\nKill any running Conkys\nand exit?"
OK="--button=OK:2"
APPLY="--button=Apply:0"
CANCEL="--button=Cancel:1"
CLOSE="--button=Close:1"
;;
esac
DLG="yad --center --undecorated --borders=20 "
DLGDEC="yad --center --borders=20 "
WINICON="--window-icon=distributor-logo-mabox --image=conky"
########## FUNCTIONS ###################################################
CPATH_REGEX='.*(conky.*\.conf|conky|\.conkyrc)'
getRunning(){
local pid cmd args CPATH
while read -r pid cmd args; do
if [[ $args =~ (-c |--config=)($CPATH_REGEX) ]]; then
CPATH=${BASH_REMATCH[2]}
[[ $CPATH = "$HOME"/* ]] || CPATH="$HOME/$CPATH"
else
CPATH=$CONKYDEFAULT
fi
[[ -f $CPATH ]] || {
echo "$0: pgrep conky parsing failed: $CPATH not a file" >&2
continue
}
runningConkys+=("$CPATH")
done < <(pgrep -ax conky)
}
# $1 holds full path to config file
# return 0 if a running conky is using that file
isRunning(){
local file=$1
for running in "${runningConkys[@]}"
do
[[ $running = "$file" ]] && return 0
done
return 1
}
fillArrays(){
local num
num="$1" # 1st arg: array index
conkysPath[$num]="$2" # full filepath
conkysArr[$num]="$3" # displayed name
if isRunning "$2"; then
checkArr[$num]="TRUE" # make checkmark in dialog
else
checkArr[$num]="FALSE"
fi
}
findConky(){
local file num display
num=0
shopt -s globstar
for file in "$CONKYPATH"/**;do
[[ -f $file ]] || continue
[[ $file =~ ${CPATH_REGEX}$ ]] || continue # ignore other than conky config files
display=${file#$CONKYPATH/}
fillArrays $num "$file" "$display"
num=$((num+1))
done
shopt -u globstar
}
writeSessions(){ # save a new sessionfile name for use by a menu
SESSIONFILE="$CONKYPATH/$1"
echo "sessionfile= $SESSIONFILE"
if ! [[ -f $SESSIONS ]];then
:> "$SESSIONS"
fi
if grep -qx "$SESSIONFILE" "$SESSIONS";then # session was previously saved
if [[ $2 = "-z" ]];then # input was from input dialog, so ask OK?
$DLG $WINICON --title="$CONKY_SESSIONFILE" --text="$FILENAME_IN_USE" $CANCEL $OK
if (( $? == 1 ));then
exit 0
fi
else # commandline is being used
echo "Session was previously saved with the same name. Overwrite it? (y|N)"
read -r ans
case "$ans" in
y|Y ) : #break
;;
* ) exit 0
;;
esac
fi
fi
cp "$SESSIONS" "$SESSIONS.bkp"
echo "$SESSIONFILE" >> "$SESSIONS"
}
loadDialog() {
local -a retConky
## Populate dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$SESS_SAVE" \
--checklist --width=400 --height=500 --multiple \
--column="$SELECT" --column="$CONF_FILE" "${LISTCONKY[@]}" \
--separator=":" \
$APPLY $CLOSE \
)
# For OK button, add to last line of yad command:
# $APPLY $OK $CLOSE \
retval=$?
if (( retval == 1 )); then # close button pressed
# if session file is empty remove it, and restore previous saved-sessions file
if [[ ! -s "$SESSIONFILE" ]];then
rm "$SESSIONFILE"
if [[ -f $SESSIONS.bkp ]]; then
mv "$SESSIONS.bkp" "$SESSIONS"
fi
fi
exit 0
fi
if ! [[ $RET ]];then # No conkys chosen
MSG="$NOTHING_SELECTED"
$DLG $WINICON --title="$TITLE" --text="$MSG" $OK $CANCEL
if [[ $? = 1 ]];then
return
fi
fi
# loop through returned choices, add to array
i=0
OIFS=$IFS # save Internal Field Separator
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retConky[$i]="$name"
i=$((i+1))
done
IFS=$OIFS # reset IFS back to default
# kill all conkys
if [[ $(pidof conky) ]];then
killall conky
fi
:> "$SESSIONFILE" # Create empty session file
# Find the chosen conkys and start them
for name in "${retConky[@]}";do # loop through checkmarked conky names
for ((j=0; j<${#conkysPath[*]}; j++));do
file=${conkysPath[j]}
display=${conkysArr[j]}
# compare with choice from dialog
if [[ $display = "$name" ]];then
echo "conky -c '$file' & sleep 1s" >> "$SESSIONFILE"
set -m # enable job control so forked conky is immune to signals
#start the conky (adjust the sleep time if required)
conky -c "$file" >/dev/null 2>&1 &
disown
set +m
sleep 1s
fi
done
done
# if there is an $OK button that returns 2, it will apply changes and exit
(( retval == 2 )) && exit 0
}
######## END FUNCTIONS #################################################
# get args passed to script (session can be saved to a different file)
while [[ -n $1 ]];do
case "$1" in
-h|--help ) echo -e "$USAGE2"
echo
exit 0
;;
-f|--files ) if [[ -n $2 ]];then
SESSIONFILE="$2" # sessionfile has been specified
writeSessions "$SESSIONFILE" # if sessionfile is new, write name to saved-sessions
break
else
echo
echo -e "\tNo saved-session file specified!"
echo -e "$USAGE1"
echo
exit 1
fi
;;
-z ) SPATH=$($DLGDEC $WINICON --entry \
--title="Save Conky sessionfile" \
--entry-label="New saved session file:" \
--text="File to be saved in <b>$CONKYPATH/</b>\n\n" \
$OK $CANCEL \
)
(( $? == 1 )) && exit 0
if [[ -z $SPATH ]];then # entry was empty
$DLG $WINICON --title="Conky sessionfile" --text="No file specified for new saved session\n\nExiting..." $OK
exit 1
else
writeSessions "$SPATH" "-z" # saved session file from input dialog
break
fi
;;
* ) echo -e "$USAGE1"
exit 1
;;
esac
shift
done
# test for ~/.config/conky/conky.conf, create a link to the default conky if necessary
if ! [[ -e $CONKYDEFAULT ]];then
if [[ -e $BLDEFAULT ]];then
ln -s "$BLDEFAULT" "$CONKYDEFAULT"
else
echo "Default conky.conf not found"
fi
fi
while true;do
runningConkys=()
getRunning
# get conky directories in .conky, add to array
findConky
LISTCONKY=()
# loop through arrays, and build list text for yad dialog
for ((j=0; j<${#conkysArr[*]}; j++));do
LISTCONKY+=("${checkArr[j]}" "${conkysArr[j]}")
done
loadDialog # LISTCONKY is global array
done
exit 0

112
bin/mb-conky-session Executable file
View File

@@ -0,0 +1,112 @@
#!/bin/bash
##
# Read saved BunsenLabs Conky session file(s) and start the conkys
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
#
# Repackaged for Manjaro by napcok <napcok@gmail.com>, March 2016
#
# To start the default conky session at login, add the following line
# to config/openbox/autostart:
#
# (sleep 2s && mb-conky-session --autostart) &
#
########################################################################
CONKYPATH="$HOME/.config/conky"
SESSIONFILE="$CONKYPATH/conky-sessionfile"
USAGE="\vUSAGE:\tmb-conky-session [OPTION(S)]...FILES
\n\tWith no command argument, the script uses the default
\t\"\$CONKYPATH/conky-session\" sessionfile
\vOPTIONS:\n\t--default\t: specify default sessionfile
\t--autostart\t: no \"kill conky\" option asked for
\tpath/to/sessionfile1 /path/to/sessionfile2 etc
\vEXAMPLES:
\tRun specified sessionfile at login:
\t\"mb-conky-session --autostart /path/to/sessionfile\"
\v\tRun default sessionfile, without killing running conkys:
\t\"mb-conky-session --autostart\"
\v\tRun several conky sessionfiles (option to kill conkys first):
\t\"mb-conky-session --default sessionfile1 sessionfile2 etc\""
### DIALOG VARIABLES
DLG="yad --center --undecorated --borders=20 "
TITLE="Mabox Conky Session"
WINICON="--window-icon=distributor-logo-mabox"
OK="--button=OK:0"
case $LANG in
pl*)
CANCEL="--button=Anuluj:1"
KILL_FIRST="Czy zamknąć najpierw działające Conky?"
;;
*)
CANCEL="--button=Cancel:1"
KILL_FIRST="Kill running conkys first?"
;;
esac
########################################################################
findArgs(){ # get command args (switches & sessionfile paths)
i=0
for arg in "$@";do
if [[ $arg = "--default" ]]; then
arg="$SESSIONFILE"
fi
if [[ $arg = "--autostart" ]]; then
NOKILL=1 # run from autostart, so don't ask to kill conkys
fi
if [[ -f $arg ]]; then # sessionfile exists
rawArr[$i]="$arg" # add sessionfiles to array
i=$(($i+1))
fi
done
# check if sessionfiles were passed to mb-conky-session
if (( ${#rawArr[@]} != 0 )); then
# remove duplicate args
sessArr=(`printf "%s\n" "${rawArr[@]}" | sort -u`)
if (( $NOKILL == 0 )); then
killConkys
fi
for SESSION in "${sessArr[@]}";do # run the conkys in the sessionfiles
source "$SESSION"
done
cat "$1" > "$SESSIONFILE"
else # --autostart used, but no sessionfiles passed to bl-conkyzen
if [[ -f $SESSIONFILE ]] && (( $NOKILL == 1 )); then
source "$SESSIONFILE" # use conky-sessionfile
else
echo -e "ERROR: sessionfile \"$SESSIONFILE\" not found. Using default" >&2
conky -c $HOME/.conkyrc # run default conky
exit 0
fi
fi
}
killConkys(){
if pidof conky &>/dev/null; then
$DLG $WINICON --title="$TITLE" --text="$KILL_FIRST"
if (( $? == 0 )); then # kill all conkys
killall conky && sleep 0.2s
fi
fi
}
NOKILL=0
if (( $# == 0 )); then # if no args, then run default sessionfile
killConkys
if [[ ! -f "$SESSIONFILE" ]]; then # run default conky
echo -e "ERROR: sessionfile \"$SESSIONFILE\" not found. Using default" >&2
conky -c $HOME/.conkyrc
exit 0
else
source "$SESSIONFILE"
fi
elif [[ $1 = "-h" ]] || [[ $1 = "--help" ]]; then
echo -e "$USAGE"
exit 0
else
findArgs $@ # get the sessionfile paths from the command args
fi
exit 0

111
bin/mb-conkyedit Executable file
View File

@@ -0,0 +1,111 @@
#!/bin/bash
#
# BunsenLabs Conky Editor
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
#
# Repackaged for Manjaro by napcok <napcok@gmail.com>, March 2016
#
########################################################################
#
# Conkys must be in $CONKYPATH
# The name must end with "conky" or "conkyrc"
#
# Checkmarked conkys will be opened in the text editor
# Multiple conkys can be chosen
#
########################################################################
CONKYPATH="$HOME/.config/conky"
### DIALOG VARIABLES
DLGDEC="yad --center --borders=20 --width=400 --height=500 "
WINICON="--window-icon=distributor-logo-mabox --image=conky "
OK="--button=OK:0"
case $LANG in
pl*)
TITLE="Edytor Conky"
CANCEL="--button=Anuluj:1"
CE_DESC="Wybierz z listy Conky do edycji.\nMożesz wybrać kilka plików konfiguracyjnych.\nMożesz dodać własne pliki konfiguracyjne Conky\ndo katalogu <i>$CONKYPATH</i>"
CE_CHOSE="Wybór"
CE_CONFFILE="Plik konfiguracyjny"
;;
*)
TITLE="Conky Editor"
CANCEL="--button=Cancel:1"
CE_DESC="Choose Conky for edit.\nYou can choose multiple files.\nYou can put your own Conky configurations\ninto <i>$CONKYPATH</i> directory."
CE_CHOSE="Choose"
CE_CONFFILE="Configuration file"
;;
esac
########## FUNCTIONS ###################################################
fillArrays(){
num="$1"
conkysPath[$num]="$2" # full filepath to conky
conkysArr[$num]="$3" # displayed name: "directory/*conky(rc)"
}
findConky(){
# search dirs for conkys files - looking for "conky" in the name
# if "*conky(rc)" then display it
num=0
# find files in CONKYPATH with conky in the name
for x in $(find "$CONKYPATH" -type f );do
f=$(basename "$x") # filename from filepath
if [[ $f = *conkyrc ]] || [[ $f = *conky ]];then
# filename ends with *conky or *conkyrc
# get directory/conkyname to display in list
CONKY=$( echo "$x" | awk -F"/" '{print $(NF-1)"/"$NF}')
fillArrays $num "$x" "$CONKY"
num=$(($num+1))
fi
done
}
######## END FUNCTIONS #################################################
# get conky directories in .conky, add to array
findConky
# loop through arrays, and build msg text for yad dialog
unset LISTCONKY
for ((j=0; j<${#conkysArr[*]}; j++));do
LISTCONKY="$LISTCONKY FALSE ${conkysArr[j]}"
done
## Populate yad dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$CE_DESC" \
--checklist \
--column="$CE_CHOSE:CHK" --column="$CE_CONFFILE:TXT" $LISTCONKY --separator=":"\
$OK $CANCEL \
)
if [[ $? == 1 ]]; then # cancel button pressed
exit 0
else
i=0
OIFS=$IFS # save Internal Field Separator
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retConky[$i]="$name"
i=$(($i+1))
done
IFS=$OIFS # reset IFS back to default
# Find the chosen conkys and edit them
for name in ${retConky[*]};do # loop through checkmarked conky names
for ((j=0; j<${#conkysPath[*]}; j++));do # traverse through elements
for f in ${conkysPath[j]};do # compare with choice from dialog
display=$( echo "$f" | awk -F"/" '{print $(NF-1)"/"$NF}')
if [[ $display = $name ]];then
xdg-open "$f"
fi
done
done
done
fi
exit 0

316
bin/mb-conkyzen Executable file
View File

@@ -0,0 +1,316 @@
#!/bin/bash
#
# BunsenLabs Conky selection and switcher script
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
# Beta tested and stamped "zen" by <Sector11>
# Rapackaged for Manjaro by napcok <napcok@gmail.com>, March 2016
#
########################################################################
#
# Conkys must be in $CONKYPATH
# The name must end with "conky" or "conkyrc"
#
# When the dialog opens, any running conkys will be checkmarked.
#
# Click "OK" and all running conkys are stopped, and all checkmarked
# conkys are started
#
# To stop a conky just uncheck it, and "OK"
#
# Running conkys are saved to a session file, and can be run with
# the "bl-conky-session" script. To start the default conky session at
# login, add the following line to autostart:
#
# (sleep 2s && bl-conky-session --autostart) &
#
# Different saved-session files can be used by running the script with:
#
# bl-conkyzen -f /path/to/sessionfile &
# bl-conkyzen -z (opens gui entry dialog for filepath)
#
########################################################################
CONKYPATH="$HOME/.config/conky"
SESSIONFILE="$CONKYPATH/conky-sessionfile"
SESSIONS="$CONKYPATH/saved-sessions" # to be used by a pipemenu
CRC="$HOME/.conkyrc"
BLDEFAULT="$CONKYPATH/MB-Default.conkyrc"
USAGE1="\v\tUSAGE:\tmb-conkyzen [OPTION]...FILES
\v\tWith no command option the script runs the gui
\v\t-h,--help : this USAGE help
\t-f,--file : FILEPATH : specify file to save session to
\t-z : Run gui filename entry dialog for new saved session"
USAGE2="\v\tUSAGE:\tmb-conkyzen [OPTION]...FILES
\v\tWith no command option the script runs the gui
\v\t-h,--help : this USAGE help
\t-f,--file : FILEPATH : specify file to save session to
\t-z : Run gui filename entry dialog for new saved session
\v\tWhen the dialog opens, any running conkys will be checkmarked.
\tClick \"OK\" and all running conkys are stopped, and all
\tcheckmarked conkys are started.
\v\tTo stop a conky just uncheck it, and \"OK\"
\v\tEXAMPLES:
\tSave session to a new saved-session file with:
\v\t\tbl-conkyzen -f sessionfile-name
\v\tTo start the default conky session at login, add the
\tfollowing line to autostart:
\v\t\t(sleep 2s && mb-conky-session --autostart) &\v"
### DIALOG VARIABLES
case $LANG in
pl*)
TITLE="Menedżer Conky"
CANCEL="--button=Anuluj:1"
CONKY_SESSIONFILE="Plik sesji Conky"
FILENAME_IN_USE="Nazwa pliku już jest używana.\n\nNadpisać?"
SAVE_SESSION="Zapisz sesję Conky"
NEW_FILE="Nowy plik zapisanej sesji:"
FILE_TO_SAVE="Plik do zapisania w <b>$CONKYPATH/</b>\n\n"
SESS_SAVE="Wybierz pliki Conky, które mają być uruchomione.\nSesja zostanie zachowana w:\n <i>$SESSIONFILE</i>"
SELECT="Wybór:CHK"
CONF_FILE="Plik konfiguracyjny:TXT"
NOTHING_SELECTED="Nic nie wybrano.\n\nWyłączyć działające Conky\ni wyjść?"
;;
*)
TITLE="Conky Manager"
CANCEL="--button=Cancel:1"
CONKY_SESSIONFILE="Conky sessionfile"
FILENAME_IN_USE="Filename already in use\n\nOverwrite it?"
SAVE_SESSION="Save Conky sessionfile"
NEW_FILE="New saved session file:"
FILE_TO_SAVE="File to be saved in <b>$CONKYPATH/</b>\n\n"
SESS_SAVE="Choose Conky file, which you like to start.\nSession will be saved to:\n <i>$SESSIONFILE</i>"
SELECT="Select:CHK"
CONF_FILE="Conky Name:TXT"
NOTHING_SELECTED="Nothing chosen.\n\nKill any running Conkys\nand exit?"
;;
esac
DLG="yad --center --undecorated --borders=20 --image=conky "
DLGDEC="yad --center --borders=20 "
WINICON="--window-icon=distributor-logo-mabox --image=conky "
OK="--button=OK:0"
########## FUNCTIONS ###################################################
conkyRunning(){ # find running conkys
# make blank tempfile, to save running conky paths
TEMPFILE=$(mktemp --tmpdir conky.XXXX)
if [[ $(pidof conky) ]];then
# test if default conky was started
for ARG in $(ps aux | grep [c]onky | awk '{print $(NF-1)}');do
if [[ $ARG = "conky" ]]; then
echo "$CRC" >> "$TEMPFILE" # 'conky -q' probably used
else # send conky filepath to tempfile
for ARG in $(ps aux | grep [c]onkyrc | awk '{print $(NF)}');do
if [[ $ARG != "-q" ]];then
echo "$ARG" >> "$TEMPFILE"
fi
done
fi
done
fi
# remove any duplicates in tempfile
TEMPFILE2=$(mktemp --tmpdir conky.XXXX)
awk '!x[$0]++' "$TEMPFILE" > "$TEMPFILE2" && mv "$TEMPFILE2" "$TEMPFILE"
}
fillArrays(){
if (( $1 != 0 ));then
num="$1" # 1st arg: array index
else
num=0 # '~/.conkyrc' added to array
fi
if (( $num == 0 ));then
cPATH="$CRC"
cARR="$USER/.conkyrc"
else
cPATH="$2" # 2nd arg: full filepath to conky
cARR="$3" # 3rd arg: displayed name: "directory/*conky(rc)"
fi
conkysPath[$num]="$cPATH"
conkysArr[$num]="$cARR"
if grep -qx "$cPATH" "$TEMPFILE";then # if conky is running (read from tempfile)
checkArr[$num]="TRUE" # make checkmark in dialog
else
checkArr[$num]="FALSE"
fi
}
findConky(){
# search dirs for conkys files - looking for "conky" in the name
# if "*conky(rc)" then display it
num=0 # added default .conkyrc
fillArrays $num "$CRC" "$USER/.conkyrc"
num=1
# find files in CONKYPATH with conky in the name
for x in $(find "$CONKYPATH" -type f );do
f=$(basename "$x") # filename from filepath
if [[ $f = *conkyrc ]] || [[ $f = *conky ]];then # filename ends with *conky or *conkyrc
# get directory/conkyname to display in list
CONKY=$( echo "$x" | awk -F"/" '{print $(NF-1)"/"$NF}')
fillArrays $num "$x" "$CONKY"
num=$(($num+1))
fi
done
}
writeSessions(){ # save a new sessionfile name for use by a menu
SESSIONFILE="$CONKYPATH/$1"
echo "sessionfile= $SESSIONFILE"
if ! [[ -f $SESSIONS ]];then
> "$SESSIONS"
fi
if grep -qx "$SESSIONFILE" "$SESSIONS";then # session was previously saved
if [[ $2 = "-z" ]];then # input was from input dialog, so ask OK?
$DLG $WINICON --title="$CONKY_SESSIONFILE" --text="$FILENAME_IN_USE" $CANCEL $OK
if (( $? == 1 ));then
exit 0
fi
else # commandline is being used
echo "Session was previously saved with the same name. Overwrite it? (y|N)"
read ans
case "$ans" in
y|Y ) break
;;
* ) exit 0
;;
esac
fi
else
cp "$SESSIONS" "$SESSIONS.bkp"
echo "$SESSIONFILE" >> "$SESSIONS"
fi
}
######## END FUNCTIONS #################################################
# get args passed to script (session can be saved to a different file)
for arg in "$@";do
case "$arg" in
-h|--help ) echo -e "$USAGE2"
echo
exit 0
;;
-f|--files ) if [[ $2 ]];then
SESSIONFILE="$2" # sessionfile has been specified
writeSessions "$SESSIONFILE" # if sessionfile is new, write name to saved-sessions
break
else
echo
echo -e "\tNo saved-session file specified!"
echo -e "$USAGE1"
echo
exit 1
fi
;;
-z ) SPATH=$($DLGDEC $WINICON --entry \
--title="$SAVE_SESSION" \
--entry-label="$NEW_FILE" \
--text="$FILE_TO_SAVE" \
$OK $CANCEL \
)
(( $? == 1 )) && exit 0
if [[ -z $SPATH ]];then # entry was empty
$DLG $WINICON --title="Conky sessionfile" --text="No file specified for new saved session\n\nExiting..." $OK
exit 1
else
writeSessions "$SPATH" "-z" # saved session file from input dialog
fi
;;
* ) if ! [[ $arg ]];then
SESSIONFILE="$SESSIONFILE" # sessionfile is default
break
else
echo -e "$USAGE1"
exit 1
fi
;;
esac
done
# test for ~/.conkyrc, create a link to the default conky if necessary
if ! [[ -e $CRC ]];then
if [[ -e $BLDEFAULT ]];then
ln -s "$BLDEFAULT" "$CRC"
else
echo "Default conkyrc not found"
fi
fi
# get conky directories in .conky, add to array
conkyRunning
findConky
# loop through arrays, and build list text for yad dialog
unset LISTCONKY
for ((j=0; j<${#conkysArr[*]}; j++));do
LISTCONKY="$LISTCONKY${checkArr[j]} ${conkysArr[j]} "
done
while ! [[ $RET ]];do
## Populate dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$SESS_SAVE" \
--checklist --width=400 --height=500 --multiple \
--column="$SELECT" --column="$CONF_FILE" $LISTCONKY \
--separator=":" \
$CANCEL $OK \
)
if [[ $? == 1 ]]; then # cancel button pressed
# restore previous saved-sessions file
[[ -f $SESSIONS.bkp ]] && mv "$SESSIONS.bkp" "$SESSIONS"
rm "$TEMPFILE"
exit 0
fi
if ! [[ $RET ]];then # No conkys chosen
MSG="$NOTHING_SELECTED"
$DLG $WINICON --title="$TITLE" --text="$MSG" $OK $CANCEL
if [[ $? = 1 ]];then
# restore previous saved-sessions file
mv "$SESSIONS.bkp" "$SESSIONS"
rm "$TEMPFILE"
continue
else
killall conky
exit 0
fi
else
> "$SESSIONFILE" # Create new session file
# loop through returned choices, add to array
i=0
OIFS=$IFS # save Internal Field Separator
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retConky[$i]="$name"
i=$(($i+1))
done
IFS=$OIFS # reset IFS back to default
# kill all conkys
if [[ $(pidof conky) ]];then
killall conky
fi
# Find the chosen conkys and start them
for name in ${retConky[*]};do # loop through checkmarked conky names
for ((j=0; j<${#conkysPath[*]}; j++));do # traverse through elements
for f in ${conkysPath[j]};do # compare with choice from dialog
display=$( echo "$f" | awk -F"/" '{print $(NF-1)"/"$NF}')
if [[ $display = $name ]];then
echo -e "conky -c $f & sleep 1s" >> "$SESSIONFILE"
#start the conky (adjust the sleep time if required)
conky -c "$f" & sleep 1s
fi
done
done
done
fi
done
rm "$TEMPFILE"
exit 0

151
bin/mb-kb Executable file
View File

@@ -0,0 +1,151 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This script reads the keybinds configuration file ("$HOME/.config/openbox/rc.xml")
# and writes them to a text file ("$HOME/.config/openbox/kbinds.txt").
# The script is used by mb-kb-pipemenu to pipe the output to the Openbox menu, or to display keybinds in a separate window
#
# Based on a script by wlourf 07/03/2010
# <http://u-scripts.blogspot.com/2010/03/how-to-display-openboxs-shortcuts.html>
#
# The original script parsed the keyboard and mouse commands from
# rc.xml, and passed them to Conkys to display on screen
#
# April 2015
# : This script outputs the keyboard keybinds to terminal or, with
# a "--gui" argument will display the output in a text window as well
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
#
# Ported to Manjaro by napcok <napcok@gmail.com> March 2016
#
########################################################################
#
# ****If Openbox xml version changes then the xml root will need
# changing as well (line 58)********
#
########################################################################
import sys,os
import datetime
import subprocess
try:
from lxml import etree
except ImportError:
import xml.etree.ElementTree as etree
# path and name of the rc.xml and saved keybinds files
rc_fpath = os.environ["HOME"] + "/.config/openbox/rc.xml"
kb_fpath = os.environ["HOME"] + "/.config/openbox/kbinds.txt"
arrShortcut=[]
gui=False
def cmdargs():
"""get command arguments"""
if len(sys.argv) > 1:
if sys.argv[1] == "--gui":
gui=True
return gui
else:
msg = "\n\n\tUSAGE: to display keybinds in a text window use 'mb-kb --gui &>/dev/null'\n\n"
msg = msg + "\tRunning the script without args will send output to the terminal\n\n"
print(msg)
sys.exit()
def keyboard():
"""read keyboard shorcuts"""
# Parse xml
strRoot="{http://openbox.org/3.4/rc}"
tree = etree.parse(rc_fpath)
root = tree.getroot()
for k in root.findall(strRoot+"keyboard/" + strRoot + "keybind"):
key = k.get("key")
action_element = k.find(strRoot+"action")
strTxt=""
strType="o " # flag for pipemenu: Openbox window command
if action_element!=None:
arrShortcut.append((key,"",""))
if action_element.get("name")=="Execute":
name_element=action_element.find(strRoot + "name")
command_element=action_element.find(strRoot + "command")
exec_element=action_element.find(strRoot + "execute")
strType="x " # flag for pipemenu: Run command
if name_element != None:
strTxt=name_element.text
elif command_element != None:
strTxt=command_element.text
elif exec_element != None:
strTxt=exec_element.text
elif action_element.get("name")=="ShowMenu":
menu_element=action_element.find(strRoot + "menu")
if menu_element != None: strTxt=menu_element.text
else:
action_name=action_element.get("name")
if action_name!=None:
strTxt=action_name
arrShortcut[len(arrShortcut)-1]=(strType,key,strTxt)
def output_keybinds(arrShortcut,gui):
"""loop through array, and format output then write to file"""
for i in range(0,len(arrShortcut)):
exe=str(arrShortcut[i][0])
keybinding=str(arrShortcut[i][1])
execute=str(arrShortcut[i][2])
if gui: #format output for text window
if len(execute)>80 :
execute=execute[:75]+"....."
line = "{:2}".format(i) + "\t" + "{:<16}".format(keybinding)\
+ "\t" + execute
else: #format text for pipemenu
line = exe + "{:<16}".format(keybinding) + "\t" + execute
print(line)
write_file(line)
def check_rcfile(fpath,mode):
"""Check if rc.xml exists, and is accessible"""
try:
f = open(fpath,mode)
except IOError as e:
return False
return True
def write_file(line):
"""Text file to store keybinds"""
f = open(kb_fpath,'a')
f.write(line + "\n")
f.close()
def check_txtfile(kb_fpath):
"""Create Text file to store keybinds"""
try:
f = open(kb_fpath,'w')
except IOError as e:
return False
return True
if __name__ == "__main__":
gui=cmdargs()
check_txtfile(kb_fpath)
if gui: # output formatted keybinds text in text window
write_file(str(datetime.date.today()) + "\trc.xml KEYBINDS")
write_file("-------------------------------\n")
if check_rcfile(rc_fpath,"r"):
keyboard()
output_keybinds(arrShortcut,gui)
else:
msg = "\nCan't open rc.xml for parsing\n\
Check the filepath given: " + rc_fpath + "\n"
print(msg)
sys.exit(1)
if gui: # output formatted keybinds text in text window
dlg = "yad --text-info --title='Openbox Keybinds' "
dlg = dlg + "--window-icon=distributor-logo-mabox "
dlg = dlg + "--filename=$HOME/.config/openbox/kbinds.txt "
dlg = dlg + "--width=700 --height=700 --fontname=Monospace "
dlg = dlg + "--button=Close"
os.system(dlg)

1218
bin/mb-obthemes Executable file

File diff suppressed because it is too large Load Diff

15
bin/mb-regenerate-menu Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
MENU=$HOME/.config/openbox/menu.xml
#Jeśli jest pipemenu to nic nie rób
if grep -q "item label" "$MENU";then
#Statyczne
if grep -q icon= "$MENU"; then
#Static menu with icons
obmenu-generator -s -i -c
else
#Static menu without icons:
obmenu-generator -s -c
fi
fi

169
bin/mb-setfont Executable file
View File

@@ -0,0 +1,169 @@
#!/bin/bash
# mb-setfont
get_obfont () {
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
NAME=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' "$cfg")
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
WEIGHT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' "$cfg")
SLANT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' "$cfg")
#notify-send.sh "OB ActiveWindow Font" "$NAME $WEIGHT $SLANT $SIZE"
CURRENT_FONT="$NAME $WEIGHT $SLANT $SIZE"
}
get_gtkfont() {
GTK2RC="$HOME"/.gtkrc-2.0
GTK3RC="$HOME"/.config/gtk-3.0/settings.ini
GTK_FONT=( $(grep "gtk-font-name" ${GTK2RC} | cut -d'"' -f2) )
GTK_FAMILY=${GTK_FONT[@]::${#GTK_FONT[@]}-1}
GTK_SIZE=${GTK_FONT[-1]}
CURRENT_FONT="${GTK_FAMILY} ${GTK_SIZE}"
}
get_menu_item_font () {
. ~/.config/mabox/mabox.conf
CURRENT_FONT="${menu_font_family} ${menu_font_size}"
}
get_menu_sep_font () {
. ~/.config/mabox/mabox.conf
CURRENT_FONT="${menu_sep_font_family:-Ubuntu} ${menu_sep_font_size:-10}"
}
selectfont () {
case "$LANG" in
pl*)
SELECTFONT="Wybierz czcionkę i jej rozmiar"
CANCEL="Anuluj"
SELECT="Wybierz"
;;
*)
SELECTFONT="Select A Font"
CANCEL="Cancel"
SELECT="Select"
;;
esac
FONT=$(yad --title="${SELECTFONT}" --font --fontname="${CURRENT_FONT}" --separate-output --button="$CANCEL:1" --button="$SELECT:0")
FONTNAME=$(echo $FONT | cut -d'|' -f1)
FONTSTYLE=$(echo $FONT | cut -d'|' -f2)
FONTSIZE=$(echo $FONT | cut -d'|' -f3)
}
font_obtitle () {
if [[ "$FONT" ]]; then
[[ "$FONTSTYLE" =~ .*"Bold".* ]] && WEIGHT="Bold" || WEIGHT="Normal"
[[ "$FONTSTYLE" =~ .*"Italic".* ]] && SLANT="Italic" || SLANT="Normal"
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v "$FONTNAME" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$FONTSIZE" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v "$WEIGHT" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v "$SLANT" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:name' -v "$FONTNAME" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$FONTSIZE" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v "$WEIGHT" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v "$SLANT" "$cfg"
openbox --reconfigure
else
exit 0
fi
}
font_gtk () {
if [[ "$FONT" ]]; then
sd "^gtk-font-name=.*" "gtk-font-name=\"${FONTNAME} ${FONTSTYLE} ${FONTSIZE}\"" ${GTK2RC}
sd "^gtk-font-name=.*" "gtk-font-name=${FONTNAME} ${FONTSTYLE} ${FONTSIZE}" ${GTK3RC}
reload-gtk
else
exit 0
fi
}
font_menu_item () {
if [[ "$FONT" ]]; then
mb-setvar menu_font_family="'${FONTNAME} ${FONTSTYLE}'"
mb-setvar menu_font_size=${FONTSIZE}
else
exit 0
fi
}
font_menu_sep () {
if [[ "$FONT" ]]; then
mb-setvar menu_sep_font_family="'${FONTNAME} ${FONTSTYLE}'"
mb-setvar menu_sep_font_size=${FONTSIZE}
else
exit 0
fi
}
font_conky_single () {
# if -f "$1"
if [[ "$FONT" ]]; then
sd "font .*=.*,$" "font = '${FONTNAME}:size=${FONTSIZE}'," ${1}
else
exit 0
fi
#fi
}
font_conky_all () {
if [[ "$FONT" ]]; then
CONKYDIR="$HOME/.config/conky"
sd "font .*=.*,$" "font = '${FONTNAME}:size=${FONTSIZE}'," ${CONKYDIR}/*mbcolor.conkyrc
else
exit 0
fi
}
t2_time1_font(){
sd "^time1_font.*$" "time1_font = ${FONTNAME} ${FONTSTYLE} ${FONTSIZE}" ${1}
killall -SIGUSR1 tint2
}
t2_time2_font(){
sd "^time2_font.*$" "time2_font = ${FONTNAME} ${FONTSTYLE} ${FONTSIZE}" ${1}
killall -SIGUSR1 tint2
}
case "$1" in
obtitle)
get_obfont
selectfont
font_obtitle
;;
gtk)
get_gtkfont
selectfont
font_gtk
;;
menu_item)
get_menu_item_font
selectfont
font_menu_item
;;
menu_sep)
get_menu_sep_font
selectfont
font_menu_sep
;;
conky_single)
selectfont
font_conky_single "${2}"
;;
conky_all)
selectfont
font_conky_all
;;
t2_time1_font)
selectfont
t2_time1_font "$2"
;;
t2_time2_font)
selectfont
t2_time2_font "$2"
;;
*)
:
;;
esac

31
bin/mb-setvar Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# mb-setvar: utility to set/change config variables
# Copyright (C) 2020 napcok <napcok@gmail.com>
if [[ $# < 1 ]]; then
self=$(basename $0)
echo "Usage: $self variable=value [/PATH/TO/CONFIG_FILE]"
echo "Current configuration:"
cat $HOME/.config/mabox/mabox.conf
exit 2
fi
if [[ $1 != *"="* ]]; then
self=$(basename $0)
echo "$self: First argument must be variable=value"
exit 2
fi
FILE=${2:-$HOME/.config/mabox/mabox.conf}
#echo $1
search=$(echo $1|cut -d= -f1)
if [[ $search =~ "bottom_img" ]]; then
sed -i /^"$search="/d $FILE
fi
if grep -Rq $search= $FILE
then #found
sed -i s/^"$search=".*$/"$1"/ $FILE
#sed -i s/^"$search".*$/"$1"/ $FILE
else #not found
echo $1 >> $FILE
fi

430
bin/mb-status Executable file
View File

@@ -0,0 +1,430 @@
#!/bin/bash
# mb-status 󰳈 󰻌 󰂪 󰮯 : updates, disk space, dir sizes
# TODO: additional configurable dirs to monitor
# TODO: own commands below updates
# TODO: own commands at bottom
CFGDIR="$HOME/.config/mabox"
UPDATES_LIST="/tmp/updates/updates_list"
AUR_UPDATES_LIST="/tmp/updates/aur_updates_list"
mkdir -p /tmp/updates
if [[ ! -f "$UPDATES_LIST" ]];then
touch "$UPDATES_LIST"
chmod 666 "${UPDATES_LIST}"
fi
if [[ ! -f "$AUR_UPDATES_LIST" ]]; then
touch "$AUR_UPDATES_LIST"
chmod 666 "$AUR_UPDATES_LIST"
fi
# all config values stored here!!!
. $HOME/.config/mabox/mabox.conf
if [ -z ${disk_limit+x} ]; then
mb-setvar disk_limit=90
mb-setvar big_pkgs=0
mb-setvar ok_icon=󰞑
mb-setvar ok_fgcolor='#008000'
mb-setvar warn_fgcolor='#FFFFFF'
mb-setvar warn_bgcolor='#ff5722'
mb-setvar dir_size_monitor=y
. $HOME/.config/mabox/mabox.conf
fi
disk_limit=${disk_limit:-70}
big_pkgs=${big_pkgs:-20}
OK_ICON=${ok_icon:-"󰕥"}
OK_FGCOLOR=${ok_fgcolor:-"#008000"}
WARN_FGCOLOR=${warn_fgcolor:-"#FFFFFF"}
WARN_BGCOLOR=${warn_bgcolor:-"#bd1e24"}
# install date
INST=$(stat -c %W /)
INSTDATE=$(stat -c %w /|awk '{print $1}')
TODAY=$(date +%s)
DIFF=$(( (TODAY - INST) / 86400 ))
if [[ "$DIFF" > "1" ]];then
DAGO="(${DIFF} ${DAYS_AGO})"
else
DAGO=""
fi
REPO=$(wc -l $UPDATES_LIST | awk '{print $1}')
AUR=$(wc -l $AUR_UPDATES_LIST | awk '{print $1}')
updates=$((REPO + AUR))
left(){
menu ipc
}
## MENU
menu(){
case $LANG in
pl*)
_KERNEL="jądro"
_PKGS="pakiety"
_BIGGEST_PKGS="największe pakiety"
_CLICK_PKG_INFO="kliknij nazwę po info"
_PKGS_STATS="Statystyki pakietów"
_QDIRPKG="QDirStat (GUI)"
_INSTALLED="zainstalowany"
_DAYS_AGO="dni"
_YESTERDAY="wczoraj"
_TODAY="dzisiaj"
_UP_TO_DATE="System jest aktualny"
_CHECK_NOW="Sprawdź aktualizacje teraz!"
_PENDING="Dostępne aktualizacje"
_GO_TO_FORUM="Idź na forum"
_UPDATE_YAY="Aktualizuj za pomocą <b>yay</b>"
_NO_AUR="(bez AUR)"
_UPDATE_PACMAN="Aktualizuj za pomocą <b>pacman</b>"
_UPDATE_PAMAC="Aktualizuj <b>Pamac</b> (gui)"
_RENEW_KEYS="Odśwież klucze (PGP)"
_RANK_MIRROR="Ranking mirrorów"
_MIRROR_RANKING="Ranking mirrorów"
_DISCS="Dyski"
_DIR_SIZE_MONITOR="Monitor wielkości katalogów"
_LOGS="Logi <small>/var/log/journal</small>"
_VACUUM_LOGS="Czyść Logi"
_VACUUM_1DAY="Zachowaj z 1 dnia"
_VACUUM_7DAYS="Zachowaj z 7 dni"
_VACUUM_200M="Zachowaj 200M"
_VACUUM_500M="Zachowaj 500M"
_PACMAN_CACHE="Cache Pacmana"
_EMPTY_PACMAN_CACHE="Wyczyść cache pacmana"
_TRASH="Śmietnik"
_OPEN="Otwórz"
_EMPTY="Opróżnij"
_QDIRSTAT="QDirStat (statystyki katalogów)"
_SETTINGS="Ustawienia"
_SHOW_BIGGEST="Pokaż listę największych pakietów"
_HOW_MANY="Ile pakietów pokazać?"
_DISABLED="wyłączone"
_DU_ALERT_LEVEL="Poziom alertu zajętości dysków"
_WARN="UWAGA"
_ICON_OK="OK ikona i kolor"
_ICON="Ikona"
_COLOR="Kolor"
_ICON_COLORS="Kolory i Ikona"
;;
*)
_KERNEL="kernel"
_PKGS="pkgs"
_BIGGEST_PKGS="biggest packages"
_CLICK_PKG_INFO="click pkgname for info"
_PKGS_STATS="Package statistics"
_QDIRPKG="QDirStat (GUI)"
_INSTALLED="installed"
_DAYS_AGO="days"
_YESTERDAY="yesterday"
_TODAY="today"
_UP_TO_DATE="System is up to date!"
_CHECK_NOW="Check for updates now"
_PENDING="Pending updates"
_GO_TO_FORUM="Update announcement"
_UPDATE_YAY="Update with <b>yay</b>"
_NO_AUR="(no AUR)"
_UPDATE_PACMAN="Update with <b>pacman</b>"
_UPDATE_PAMAC="Update with <b>Pamac</b> (gui)"
_RENEW_KEYS="Renew PGP keys"
_RANK_MIRROR="Rank mirrors"
_MIRROR_RANKING="Mirror ranking"
_DISCS="Discs"
_DIR_SIZE_MONITOR="Directory size monitor"
_LOGS="Logs <small>/var/log/journal</small>"
_VACUUM_LOGS="Vacuum Logs"
_VACUUM_1DAY="Keep 1 day"
_VACUUM_7DAYS="Keep 7 days"
_VACUUM_200M="Keep 200M"
_VACUUM_500M="Keep 500M"
_PACMAN_CACHE="Pacman cache"
_EMPTY_PACMAN_CACHE="Clean pacman cache"
_TRASH="Trash Can"
_OPEN="Open"
_EMPTY="Empty"
_QDIRSTAT="QDirStat (directory statistics)"
_SETTINGS="Settings"
_SHOW_BIGGEST="Show biggest pkgs list"
_HOW_MANY="How many?"
_DISABLED="disabled"
_DU_ALERT_LEVEL="Disk usage alert level"
_WARN="WARNING"
_ICON_OK="OK icon and color"
_ICON="Icon"
_COLOR="Color"
_ICON_COLORS="Colors and Icon"
;;
esac
tint2-send refresh-execp mb-status
[[ "${1}" == "settings" ]] && option="--checkout=settings" || option=""
PKGS=$(pacman -Qq 2>/dev/null | wc -l)
# kernel version
KERN="${KERN:-$(uname -sr | awk '{print $2}')}"
KERN="${KERN/-*/}"
#KERN="${KERN/linux/}"
#KERN="${KERN,,}"
out+=("^sep(<b>Mabox</b> Linux <b>$(lsb_release -rs)</b> <small><i>$(lsb_release -cs)</i></small>)")
out+=("<big></big> $_KERNEL: <b>${KERN}</b>,manjaro-settings-manager -m msm_kernel")
## Biggest PKGS
if hash expac 2>/dev/null && [[ "${big_pkgs}" -gt 0 ]];then
out+=("<big></big> $_PKGS: <b>$PKGS</b>,^checkout(pkgs)")
out2+=("^tag(pkgs)")
out2+=("^sep(${big_pkgs} $_BIGGEST_PKGS)")
out2+=("^sep(<i>$_CLICK_PKG_INFO</i>)")
count=0
while IFS=' ' read -r pkgname size rest
do
((count++))
out2+=("$(printf '<small>%2s.</small>' $count) $pkgname $size M,mb-cli pkginfo $pkgname")
done< <(expac -H M '%-20n %10m' | sort -rhk 2 | head -n "${big_pkgs}")
out2+=("^sep($_PKGS_STATS)")
out2+=(" <small>yay -Ps</small>,mb-cli stats")
if hash qdirstat 2>/dev/null;then
out2+=("<big>󰀻</big> $_QDIRPKG,qdirstat pkg:/")
fi
else
out+=("<big></big> $_PKGS: <b>$PKGS</b>,mb-cli stats")
fi
if [[ "$DIFF" -gt "1" ]];then
DAGO="<b>$DIFF</b> ${_DAYS_AGO}"
elif [[ "$DIFF" = "1" ]];then
DAGO="<b>$_YESTERDAY</b>"
else
DAGO="<b>$_TODAY</b>"
fi
if hash calamares 2>/dev/null ;then
:
else
out+=("<big></big> $_INSTALLED: <small>$INSTDATE</small> $DAGO,mcc")
fi
if [[ "${updates}" == 0 ]];then
out+=("^sep(<span fgcolor='${OK_FGCOLOR}'> ${OK_ICON} </span> <small><i>$_UP_TO_DATE</i></small>)")
out+=("<big>󰦛</big> $_CHECK_NOW,checkupdates.sh -p")
out+=("^sep()")
out+=("$_RANK_MIRROR,^checkout(mirrors)")
out2+=("^tag(mirrors)")
out2+=("^sep($_MIRROR_RANKING)")
out2+=("Fasttrack <small>pacman-mirrors -f5</small>,mb-cli mirrors")
out2+=("All <small>pacman-mirrors -i -c all</small>,mb-cli mirrors_all")
out2+=("Geoip <small>pacman-mirrors -i --geoip</small>,mb-cli mirrors_geo")
fi
if [[ "${updates}" != 0 ]];then
out+=("^sep(<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 󰮯 <i>$_PENDING:</i> ${updates} </span>)")
out+=("^sep(<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> repo: ${REPO} AUR: ${AUR} </span>)")
[[ "${updates}" -gt 10 ]] && out+=("$_GO_TO_FORUM: <b>Mabox</b> forum, xdg-open https://forum.maboxlinux.org/c/news-development/updates/25" "$_GO_TO_FORUM: <b>Manjaro</b> forum,xdg-open https://forum.manjaro.org/c/announcements/stable-updates/" "^sep()")
out+=("$_UPDATE_YAY $_NO_AUR,mb-cli update-noaur")
out+=("$_UPDATE_YAY,mb-cli update")
out+=("$_UPDATE_PACMAN,mb-cli pacupdate")
out+=("$_RENEW_KEYS,^term(sudo pacman -Sy archlinux-keyring manjaro-keyring mabox-keyring;read -p "${FINISHED}"")
#out+=("^sep()")
#out+=("$_UPDATE_PAMAC,pamac-manager --updates")
out+=("^sep(<small><i>$_MIRROR_RANKING</i></small>)")
out+=("Fasttrack <small>pacman-mirrors -f5</small>,mb-cli mirrors")
out+=("All <small>pacman-mirrors -i -c all</small>,mb-cli mirrors_all")
out+=("Geoip <small>pacman-mirrors -i --geoip</small>,mb-cli mirrors_geo")
fi
## DISCS
if hash qdirstat 2>/dev/null;then
qdir=" -q"
else
qdir=""
fi
if [[ "${disk_limit}" -gt "0" ]];then
out+=("^sep($_DISCS)")
while read DEVICE SIZE USED FREE PERCENT MOUNT
do
[[ "${#MOUNT}" -gt "10" ]] && MOUNTLBL=${MOUNT##*/} || MOUNTLBL=${MOUNT}
[[ "${#MOUNTLBL}" -gt "10" ]] && MOUNTLBL=${MOUNTLBL:0:12}
[[ "${MOUNT}" = *"media"* ]] && ICON="<big>󱊟</big>" || ICON="<big>󰋊</big>"
[[ "${PERCENT::-1}" -ge "${disk_limit}" ]] && PERCENT="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${PERCENT} </span>" || PERCENT="<span> ${PERCENT} </span>"
out+=("$ICON $MOUNTLBL <small>$DEVICE</small> $PERCENT,^pipe(jgbrowser ${MOUNT}${qdir})")
done < <(df -h | grep '^/dev' | grep -v 'boot' | grep -v 'loop' | grep -v '/run/media')
fi
## DIR SIZE MONITOR
if [[ "${dir_size_monitor}" == "y" ]];then
out+=("^sep($_DIR_SIZE_MONITOR)")
logsize=$(du -sh /var/log/journal|awk '{print $1}')
paccachesize=$(du -sh /var/cache/pacman/pkg|awk '{print $1}')
trashsize=$(du -sh ~/.local/share/Trash|awk '{print $1}')
downsize=$(du -sh $(xdg-user-dir DOWNLOAD)|awk '{print $1}')
[[ "${logsize}" == *G* ]] && logsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${logsize} </span>" || logsize="<span> ${logsize} </span>"
if [[ "${paccachesize}" == *K* ]];then
paccachesize="<span fgcolor='${OK_FGCOLOR}'> </span>"
else
[[ "${paccachesize}" == *G* ]] && paccachesize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${paccachesize} </span>" || paccachesize="<span> ${paccachesize} </span>"
fi
if [[ "${trashsize}" == *K* ]];then
trashsize="<span fgcolor='${OK_FGCOLOR}'> </span>"
else
[[ "${trashsize}" == *G* ]] && trashsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${trashsize} </span>" || trashsize="<span> ${trashsize} </span>"
fi
[[ "${downsize}" == *G* ]] && downsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${downsize} </span>" || downsize="<span> ${downsize} </span>"
out+=("\"\"\"$_LOGS ${logsize}\"\"\",^checkout(logs)")
out2+=("^tag(logs)")
out2+=("^sep($_VACUUM_LOGS)")
out2+=("$_VACUUM_1DAY,mb-cli vacuum 1d")
out2+=("$_VACUUM_7DAYS,mb-cli vacuum 7d")
out2+=("$_VACUUM_200M,mb-cli vacuum 200M")
out2+=("$_VACUUM_500M,mb-cli vacuum 500M")
out+=("\"\"\"$_PACMAN_CACHE ${paccachesize}\"\"\",^checkout(paccache)")
out2+=("^tag(paccache)")
out2+=("^sep($_PACMAN_CACHE)")
out2+=("$_EMPTY_PACMAN_CACHE,mb-cli paccache_clean")
out+=("\"\"\"$_TRASH ${trashsize}\"\"\",^checkout(trash)")
out2+=("^tag(trash)")
out2+=("^sep($_TRASH)")
out2+=("$_EMPTY $_TRASH,rm -r ~/.local/share/Trash/*/*;mb-status menu")
out2+=("$_OPEN $_TRASH,pcmanfm trash://")
out+=("\"\"\"$(basename $(xdg-user-dir DOWNLOAD)) ${downsize}\"\"\",^pipe(jgbrowser $(xdg-user-dir DOWNLOAD)$qdir)")
fi
out+=("^sep()")
out+=(" $_SETTINGS,^checkout(settings)")
out2+=("^tag(settings)")
out2+=("^sep($_SETTINGS)")
[[ "$1" == "settings" ]] && out2+=("${arrow_string_left} ${arrow_string_left} ${arrow_string_left},^back()" "^sep()")
# BIG PKGS
if hash expac 2>/dev/null;then
[[ "${big_pkgs}" -gt "0" ]] && out2+=("<big></big> $_SHOW_BIGGEST,^checkout(biggest)") || out2+=("<big>󰄱</big> $_SHOW_BIGGEST,^checkout(biggest)")
out3+=("^tag(biggest)")
out3+=("^sep($_HOW_MANY)")
[[ "${big_pkgs}" == "0" ]] && out3+=("<big>綠</big> 0 ($_DISABLED),mb-setvar big_pkgs=0;mb-status menu ipc") || out3+=("<big>祿</big> 0 ($_DISABLED),mb-setvar big_pkgs=0;mb-status menu ipc")
out3+=("^sep()")
[[ "${big_pkgs}" == "10" ]] && out3+=("<big>綠</big> 10,mb-setvar big_pkgs=10;mb-status menu ipc") || out3+=("<big>祿</big> 10,mb-setvar big_pkgs=10;mb-status menu ipc")
[[ "${big_pkgs}" == "20" ]] && out3+=("<big>綠</big> 20,mb-setvar big_pkgs=20;mb-status menu ipc") || out3+=("<big>祿</big> 20,mb-setvar big_pkgs=20;mb-status menu ipc")
[[ "${big_pkgs}" == "30" ]] && out3+=("<big>綠</big> 30,mb-setvar big_pkgs=30;mb-status menu ipc") || out3+=("<big>祿</big> 30,mb-setvar big_pkgs=30;mb-status menu ipc")
[[ "${big_pkgs}" == "40" ]] && out3+=("<big>綠</big> 40,mb-setvar big_pkgs=40;mb-status menu ipc") || out3+=("<big>祿</big> 40,mb-setvar big_pkgs=40;mb-status menu ipc")
fi
out2+=("^sep($_DU_ALERT_LEVEL)")
[[ "$disk_limit" == "0" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 0 ($_DISABLED) </span>,mb-setvar disk_limit=0;mb-status menu settings") || out2+=("<big>祿</big> 0 ($_DISABLED),mb-setvar disk_limit=0;mb-status menu settings")
[[ "$disk_limit" == "75" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 75% </span>,mb-setvar disk_limit=75;mb-status menu settings") || out2+=("<big>祿</big> 75%,mb-setvar disk_limit=75;mb-status menu settings")
[[ "$disk_limit" == "80" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 80% </span>,mb-setvar disk_limit=80;mb-status menu settings") || out2+=("<big>祿</big> 80%,mb-setvar disk_limit=80;mb-status menu settings")
[[ "$disk_limit" == "85" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 85% </span>,mb-setvar disk_limit=85;mb-status menu settings") || out2+=("<big>祿</big> 85%,mb-setvar disk_limit=85;mb-status menu settings")
[[ "$disk_limit" == "90" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 90% </span>,mb-setvar disk_limit=90;mb-status menu settings") || out2+=("<big>祿</big> 90%,mb-setvar disk_limit=90;mb-status menu settings")
[[ "$disk_limit" == "95" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 95% </span>,mb-setvar disk_limit=95;mb-status menu settings") || out2+=("<big>祿</big> 95%,mb-setvar disk_limit=95;mb-status menu settings")
out2+=("^sep($_DIR_SIZE_MONITOR)")
[[ "${dir_size_monitor}" == "y" ]] && out2+=("<big></big> $_DIR_SIZE_MONITOR,mb-setvar dir_size_monitor=n;mb-status menu settings") ||out2+=("<big>󰄱</big> $_DIR_SIZE_MONITOR,mb-setvar dir_size_monitor=y;mb-status menu settings")
out2+=("^sep($_ICON_COLORS)")
icons=("󰕥" "󰞑" "" "" "" "" "󰸞")
out2+=("<span fgcolor='${OK_FGCOLOR}'><big>${OK_ICON}</big></span> $_ICON_OK,^checkout(icon)")
out3+=("^tag(icon)")
out3+=("^sep($_ICON)")
for i in ${icons[@]};do
[[ "${OK_ICON}" == "${i}" ]] && out3+=("<big>綠 <span fgcolor='${OK_FGCOLOR}'>$i</span></big>") || out3+=("<big>祿 <span fgcolor='${OK_FGCOLOR}'>$i</span></big>,mb-setvar ok_icon=${i};mb-status menu settings")
done
okcols=("#EEEEEE" "#CCCCCC" "#AAAAAA" "#222222" "#a4c400" "#60a917" "#288C44" "#008a00" "#00aba9" "#1ba1e2" "#3e65ff" "#f472d0")
warncols=("#d80073" "#a20025" "#e51400" "#fa6800" "#f0a30a" "#e3c800")
#out2+=("<span bgcolor='$OK_FGCOLOR'> </span> $_COLOR_OK,^checkout(colok)")
#out3+=("^tag(colok)")
out3+=("^sep($_COLOR)")
for i in ${okcols[@]};do
[[ "${OK_FGCOLOR}" == "${i}" ]] && out3+=("<big>綠</big> <span bgcolor='${i}'> </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='${i}'> </span>,mb-setvar ok_fgcolor=${i};mb-status menu settings")
done
out2+=("<span bgcolor='$WARN_BGCOLOR' fgcolor='$WARN_FGCOLOR'> $_WARN </span>,^checkout(colwarn)")
out3+=("^tag(colwarn)")
out3+=("^sep($_WARN)")
[[ "${WARN_BGCOLOR}" == "#bd1e24" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#bd1e24' fgcolor='#FFFFFF'> warning </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#bd1e24' fgcolor='#FFFFFF'> warning </span>,mb-setvar warn_bgcolor='#bd1e24' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
[[ "${WARN_BGCOLOR}" == "#e91e63" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#e91e63' fgcolor='#FFFFFF'> pink </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#e91e63' fgcolor='#FFFFFF'> pink </span>,mb-setvar warn_bgcolor='#e91e63' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
[[ "${WARN_BGCOLOR}" == "#ff5722" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#ff5722' fgcolor='#FFFFFF'> deep orange </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#ff5722' fgcolor='#FFFFFF'> deep orange </span>,mb-setvar warn_bgcolor='#ff5722' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
[[ "${WARN_BGCOLOR}" == "#ff9800" && "${WARN_FGCOLOR}" == "#000000" ]] && out3+=("<big>綠</big> <span bgcolor='#ff9800' fgcolor='#000000'> orange </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#ff9800' fgcolor='#000000'> orange </span>,mb-setvar warn_bgcolor='#ff9800' ${CONF_FILE};mb-setvar warn_fgcolor='#000000' ${CONF_FILE};mb-status menu settings")
[[ "${WARN_BGCOLOR}" == "#f6c700" && "${WARN_FGCOLOR}" == "#000000" ]] && out3+=("<big>綠</big> <span bgcolor='#f6c700' fgcolor='#000000'> yellow </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#f6c700' fgcolor='#000000'> yellow </span>,mb-setvar warn_bgcolor='#f6c700' ${CONF_FILE};mb-setvar warn_fgcolor='#000000' ${CONF_FILE};mb-status menu settings")
[[ "${WARN_BGCOLOR}" == "#000000" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#000000' fgcolor='#FFFFFF'> black </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#000000' fgcolor='#FFFFFF'> black </span>,mb-setvar warn_bgcolor='#000000' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
#for i in ${warncols[@]};do
#[[ "${COLOR_WARN}" == "${i}" ]] && out3+=("<big>綠</big> <span bgcolor='${i}'> </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='${i}'> </span>,mb-setvar color_warn=${i} ${CONF_FILE};mb-status menu settings")
#done
[[ "$1" == "settings" ]] && out2+=("^sep()" "${arrow_string_left} ${arrow_string_left} ${arrow_string_left},^back()")
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
MENU_PADDING_TOP=${jgtools_padding:-0}
POSITION_MODE="center"
MENU_HALIGN="center"
MENU_VALIGN="center"
[[ "${1}" == "ipc" ]] && POSITION_MODE="ipc"
[[ "${1}" == "settings" ]] && POSITION_MODE="ipc"
#notify-send.sh "Pos" "${POSITION_MODE}"
JGWIDTH=300
TABS=190
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
icons=0
iconmargin=0
mkconfigfile
echo menu_height_mode=dynamic >> ${CONFIG_FILE}
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
$(printf '%s\n' "${out3[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} ${option} 2>/dev/null
}
#dnotify(){
#LINK="exo-open --launch WebBrowser maboxlinux.org/donate"
#yad --width="400" --center --height="80" --window-icon="mbcc" --borders="10" --image="emote-love" --image-on-top --title "Request for Donation" \
#--text-align="center" --text="<big>Donate to Mabox </big>" \
#--form --align="center" \
#--field="Mabox needs your help... Donations fund":LBL \
#--field="development and infrastructure":LBL \
#--field="important for Mabox's continued existence.":LBL \
#--button="Donate":"$LINK" --button="No Thanks":"0"
#}
#updates=100
status(){
#if [[ "$DIFF" -gt "1" ]];then
#DDATE=$(date +%Y-%m-%d)
#if [[ $((DIFF % 100)) == "0" ]] && [[ ! -f "$CFGDIR/.$DDATE" ]];then
#touch "$CFGDIR/.$DDATE"
#dnotify &>/dev/null
#fi
#fi
#disk space
dirty=0
if [[ "${disk_limit}" -gt "0" ]];then
while read DEVICE SIZE USED FREE PERCENT MOUNT
do
[[ "${PERCENT::-1}" -ge "${disk_limit}" ]] && dirty=1
done < <(df -h | grep '^/dev' | grep -v 'boot' | grep -v 'loop' | grep -v '/run/media')
fi
[[ "${dirty}" == 1 ]] && msg="<span fgcolor='${WARN_BGCOLOR}'> 󰻌 </span>" || msg="<span fgcolor='${OK_FGCOLOR}'> ${OK_ICON} </span>"
[[ "${updates}" -gt 0 ]] && msg="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 󰮯 <sup><small><b>${updates}</b></small></sup> </span>"
echo "${msg}"
}
case "$1" in
status) status;;
left) left;;
menu) menu "$2";;
esac

254
bin/mb-tint2-manager Executable file
View File

@@ -0,0 +1,254 @@
#!/bin/bash
#
# bl-tint2-manager: a BunsenLabs tint2 selection and switcher script
# Copyright (C) 2015-2019 damo <damo@bunsenlabs.org>
# 2019-2020 John Crawley <john@bunsenlabs.org>
# Ported to Mabox by napcok <napcok@gmail.com>, August 2020
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
#
# Tint2 config files must be in $TINT2PATH
#
# When the dialog opens, any running tint2s will be checkmarked.
#
# Click "Apply" and all running tint2s are stopped,
# and all checkmarked tint2s are started.
#
# To stop a tint2 just uncheck it, and "Apply".
#
# Running tint2s are saved to a session file, and can be run with
# the "tint2-session" script. To start them at login, add the
# following line to autostart:
#
# mb-tint2-session
#
########################################################################
TINT2PATH="$HOME/.config/tint2"
TINT2DEFAULT="$TINT2PATH/tint2rc" # tint2 will create this if it doesn't exist
SESSIONFILE="$TINT2PATH/tint2-sessionfile"
USAGE='mb-tint2-manager is a tint2 selection and switcher script
which uses yad to generate a graphical user interface.
Usage: mb-tint2-manager
or: mb-tint2-manager -h|--help
Optional arguments:
-h | --help Show this message (no other options are supported at this time)
Use:
With no command option the script runs the gui
Tint2 config files must be in HOME/.config/tint2/
When the dialog opens, any running tint2s will be checkmarked.
Click "Apply" or "OK" and all running tint2s are stopped,
and all checkmarked tint2s are started.
To stop a tint2 just uncheck it, and click "Apply" or "OK".
Click "Apply" to return to the dialog after applying changes,
click "OK" to close the window after applying changes,
click "Close" to close the window without applying any more changes.
Running tint2s are saved to a session file, and can be run with
the "tint2-session" script. To start them at login, add the
following line to autostart:
mb-tint2-session
'
### DIALOG VARIABLES
DLGDEC="yad --center --borders=20 "
WINICON="--window-icon=distributor-logo-mabox --image=tint2conf"
case $LANG in
pl*)
TITLE="Menedżer paneli Tint2"
OK="--button=OK:2"
APPLY="--button=Zastosuj:0"
CANCEL="--button=Anuluj:1"
CLOSE="--button=Zamknij:1"
SELECT_TINT="Wybierz Tint2 z listy, po kliknięcu <b>Zastosuj</b> wszystkie zaznaczone zostaną uruchomione."
SELECT="Wybór"
TINT_CONF_FILE="plik konfiguracji tint2"
;;
es*)
TITLE="Gestor de panel(es) tint2"
OK="--button=Aceptar:2"
APPLY="--button=Aplicar:0"
CANCEL="--button=Cancelar:1"
CLOSE="--button=Cerrar:1"
SELECT_TINT="Selecciona panel(es) de la lista. Dale clic a <b>Aplicar</b> para ejecutar el seleccionado."
SELECT="Seleccionar"
TINT_CONF_FILE="Nombrar panel tint2"
;;
*)
TITLE="Tint2 Panels Manager"
OK="--button=OK:2"
APPLY="--button=Apply:0"
CANCEL="--button=Cancel:1"
CLOSE="--button=Close:1"
SELECT_TINT="Select Tint2s from the list. Click <b>Apply</b> to start all selected."
SELECT="Select"
TINT_CONF_FILE="tint2 Name"
;;
esac
########################################################################
getRunning(){
local pid cmd args TPATH
while read -r pid cmd args; do
TPATH=${args#-c } # tint2 will start even without -c before filepath
if [[ -z $TPATH ]]; then
TPATH=$TINT2DEFAULT
elif [[ $TPATH != "$HOME"/* ]]; then
TPATH="$HOME/$TPATH"
fi
[[ -f $TPATH ]] || {
echo "$0: pgrep tint2 parsing failed: $TPATH not a file" >&2
continue
}
runningTints+=("$TPATH")
done < <(pgrep -ax tint2)
}
# $1 holds full path to config file
# return 0 if a running tint2 is using that file
isRunning(){
local file=$1
for running in "${runningTints[@]}"
do
[[ $running = "$file" ]] && return 0
done
return 1
}
fillArrays(){
num="$1"
tintsPath[$num]="$2" # full filepath to the tint2
tintsArr[$num]="$3" # displayed name
# see if config file matches one of the running tints
if isRunning "$2";then
checkArr[$num]="TRUE" # make checkmark in dialog
else
checkArr[$num]="FALSE"
fi
}
findTint(){
# search dirs for tint2 config files
local file num display
num=0
shopt -s globstar
#for file in "$TINT2PATH"/**;do
for file in $(find $TINT2PATH -type f -name *tint2rc);do
[[ -f $file ]] || continue
[[ $file = *~ ]] && continue # ignore backups
grep -q "panel_monitor" "$file" || continue # not a tint2rc file
display=${file#$TINT2PATH/}
fillArrays $num "$file" "$display"
num=$((num+1))
done
shopt -u globstar
}
loadDialog() {
local RET retval i pid cmd name file display
declare -a retTint
## Populate dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$SELECT_TINT" \
--checklist --width=400 --height=500 \
--column="$SELECT" --column="$TINT_CONF_FILE" "${LISTTINT[@]}" --separator=":" \
$APPLY $CLOSE \
)
# For OK button, add to last line of yad command:
# $APPLY $OK $CLOSE \
retval=$?
if (( retval == 1 )); then # close button pressed
exit 0
fi
:> "$SESSIONFILE" # Create new session file
# loop through returned choices, add to array
i=0
OIFS=$IFS # copy original IFS
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retTint[$i]=$name
i=$((i+1))
done
IFS=$OIFS # reset IFS
# kill all tint2s
pgrep -a tint2 | while read -r pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
fi
done
for name in "${retTint[@]}";do # loop through checkmarked tint2 names
for ((j=0; j<${#tintsPath[*]}; j++));do # traverse through elements
file=${tintsPath[j]}
display=${tintsArr[j]}
# see if it matches the returned name
if [[ $display = "$name" ]];then
echo "$file" >> "$SESSIONFILE"
set -m # enable job control so forked tint2 is immune to signals
# start the tint2 (adjust the sleep time if required)
tint2 -c "$file" >/dev/null 2>&1 &
disown
set +m
sleep 1s
fi
done
done
# if there is an $OK button that returns 2, it will apply changes and exit
(( retval == 2 )) && exit 0
}
# get any commandline arguments
if ! (( $# == 0 ));then
for arg in "$@";do
if [[ $1 = "-h" ]] || [[ $1 = "--help" ]];then
echo -e "$USAGE"
exit 0
else
echo -e "\tERROR: sorry I don't understand \"${arg}\""
echo -e "$USAGE"
exit 1
fi
done
fi
while true;do
runningTints=()
# get tint2 directories in .tint2, add to array
getRunning
findTint
LISTTINT=()
# loop through arrays, and build list text for yad dialog
for ((j=0; j<${#tintsArr[*]}; j++));do
LISTTINT+=("${checkArr[j]}" "${tintsArr[j]}")
done
loadDialog #"$LISTTINT" now a global array
done
exit 0

81
bin/mb-tint2-session Executable file
View File

@@ -0,0 +1,81 @@
#!/bin/bash
##
# Read a saved BunsenLabs Tint2 session file and start the tint2s
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
#
# To start the chosen Tint2 session at login, add the following line
# to config/openbox/autostart:
#
# (sleep 2s && mb-tint2-session) &
#
########################################################################
TINT2PATH="$HOME/.config/tint2"
SESSIONFILE="$TINT2PATH/tint2-sessionfile"
USAGE=$(
echo -e "\vUSAGE: with no command argument, the script uses the chosen"
echo -e "\tTint2 session file \"$TINT2PATH/tint2-sessionfile\","
echo -e "\tif it exists, otherwise the default tint2rc is used"
echo -e "\v\tTo start them at login, add the following line to autostart:"
echo -e "\v\t\t(sleep 2s && mb-tint2-session) &"
)
findArgs(){ # get command args
for arg in "$@";do
if [[ $1 = "-h" ]] || [[ $1 = "--help" ]];then
echo "$USAGE"
exit 0
else
echo -e "\tERROR: sorry I don't understand the input"
echo "$USAGE"
exit 0
fi
done
}
testSessionfile(){
if test -f "$1" &>/dev/null;then # sessionfile found
killTints
while read line;do
if test -z $line &>/dev/null;then
continue
else
if test -e "$HOME$line";then
tint2 -c "$HOME$line" &
sleep 1s
echo "$HOME$line" >> "$SESSIONFILE".tmp
else
tint2 -c "$line" &
fi
fi
done < "$1"
if test -f "$SESSIONFILE".tmp &>/dev/null;then
cat "$SESSIONFILE".tmp > "$SESSIONFILE"
rm "$SESSIONFILE".tmp
fi
else
echo -e "Created sessionfile \"$1\"\nRunning default tint2rc" 2>&1
echo "$HOME/.config/tint2/tint2rc" > "$SESSIONFILE"
killTints
tint2 -c "$TINT2PATH/tint2rc" &>/dev/null
fi
}
killTints(){
pgrep -a tint2 | while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
fi
done
}
if [ $# -eq 0 ];then # if no args, then run default sessionfile
testSessionfile "$SESSIONFILE"
else
findArgs "$@"
fi
# restart compositor in case of rendering problems
if pgrep picom;then mabox-compositor --restart; fi
exit 0

105
bin/mb-tint2edit Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/bash
#
# Mabox Tint2 Editor
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
# Ported to Manjaro by napcok <napcok@gmail.com>
#
########################################################################
#
# Tint2 files must be in $TINT2PATH
#
# Checkmarked tint2s will be opened in the text editor
# Multiple tint2s can be chosen
#
########################################################################
TINT2PATH="$HOME/.config/tint2"
### DIALOG VARIABLES
DLGDEC="yad --center --borders=20 --width=400 --height=600 "
WINICON="--window-icon=distributor-logo-mabox --image=tint2conf"
case $LANG in
pl*)
TITLE="Edytor Tint2"
OK="--button=OK:0"
CANCEL="--button=Anuluj:1"
TE_DESC="Wybierz pliki konfiguracji Tint2 do edycji.\nMożesz wybrać kilka.\nDodatkowe pliki konfiguracyjne można skopiować do katalogu: \n<i>$TINT2PATH</i>"
TE_CHOOSE="Wybór"
TE_CONFFILE="Plik konfiguracyjny"
;;
*)
TITLE="Tint2 Editor"
OK="--button=OK:0"
CANCEL="--button=Cancel:1"
TE_DESC="Choose Tint2rc file for edit.\nYou can choose multiple files.\nYou can put your own Tint2 configurations\ninto <i>$TINT2PATH</i> directory."
TE_CHOOSE="Choose"
TE_CONFFILE="Configuration file"
;;
esac
########## FUNCTIONS ###################################################
fillArrays(){
num="$1"
tintsPath[$num]="$2" # full filepath to tint2
tintsArr[$num]="$3" # displayed name: "directory/tintfile"
}
findTint(){
# search dirs for tint2 config files
num=0
for x in $(find $TINT2PATH -type f );do
# check if likely tint2 config file
pm=$(grep "panel_monitor" "$x")
if [[ $pm ]];then
TINT2=$( echo $x | awk -F"/" '{print $(NF-1)"/"$NF}')
fillArrays $num $x $TINT2
num=$(($num+1))
fi
done
}
######## END FUNCTIONS #################################################
# get tint2 directories, add to array
findTint
# loop through arrays, and build msg text for yad dialog
unset LISTINT
for ((j=0; j<${#tintsArr[*]}; j++));do
LISTINT="$LISTINT FALSE ${tintsArr[j]} "
done
## Populate dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$TE_DESC" \
--checklist \
--column="$TE_CHOOSE:CHK" --column="$TE_CONFFILE:TXT" $LISTINT --separator=":" \
$CANCEL $OK \
)
if (( $? == 1 )); then # cancel button pressed
exit 0
else
i=0
OIFS=$IFS # save Internal Field Separator
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retTint[$i]="$name"
i=$(($i+1))
done
IFS=$OIFS # reset IFS back to default
# Find the chosen tint2s and edit them
for name in ${retTint[*]};do # loop through checkmarked tint2 names
for ((j=0; j<${#tintsPath[*]}; j++));do # traverse through elements
for f in ${tintsPath[j]};do # compare with choice from dialog
display=$( echo "$f" | awk -F"/" '{print $(NF-1)"/"$NF}')
if [[ $display = $name ]];then
xdg-open "$f"
fi
done
done
done
fi
exit 0

37
bin/mb-tint2restart Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
#
# mb-tint2restart to be used by mb-tint2-pipemenu
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
# and johnraff <john@bunsenlabs.org> July 2015
# Potred to Manjaro by napcok <napcok@gmail.com>
declare -A commands # associative array
while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
commands[$cmd]=1 # duplicate commands will be launched only once
fi
done <<< "$(pgrep -a tint2)"
sleep 1
# any processes still running will be killed with SIGKILL
while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill -KILL "$pid"
commands[$cmd]=1
fi
done <<< "$(pgrep -a tint2)"
sleep 1
for i in "${!commands[@]}" # go through the indexes
do
(setsid $i &)
sleep 0.1
done
sleep 1
if pgrep picom;then mabox-compositor --restart; fi
exit 0

168
bin/mb-tint2zen Executable file
View File

@@ -0,0 +1,168 @@
#!/bin/bash
#
# Mabox tint2 selection and switcher script
#
# Written by damo <damo@bunsenlabs.org> for BunsenLabs Linux, April 2015
# Ported to Manjaro by napcok <napcok@gmail.com>, March 2016
########################################################################
#
# Tint2 config files must be in $TINT2PATH
#
# When the dialog opens, any running tint2s will be checkmarked.
#
# Click "OK" and all running tint2s are stopped, and all checkmarked
# tint2s are started
#
# To stop a tint2 just uncheck it, and "OK"
#
# Running tint2s are saved to a session file, and can be run with
# the "tint2-session" script. To start them at login, add the
# following line to autostart:
#
# (sleep 2s && mb-tint2-session) &
#
########################################################################
DEBUGFILE="$HOME/.config/mb-tint2-debug.txt"
TINT2PATH="$HOME/.config/tint2"
SESSIONFILE="$TINT2PATH/tint2-sessionfile"
USAGE="\v\tUSAGE:\n\tWith no command argument, the script uses the chosen
\tTint2 session file \"$TINT2PATH/tint2-sessionfile\",
\tif it exists, otherwise the default tint2rc is used
\v\tTo start them at login, add the following line to autostart:
\v\t\t(sleep 2s && mb-tint2-session) &"
### DIALOG VARIABLES
DLGDEC="yad --center --borders=20"
OK="--button=OK:0"
WINICON="--window-icon=distributor-logo-mabox --image=tint2conf"
case $LANG in
pl*)
TITLE="Menedżer paneli Tint2"
CANCEL="--button=Anuluj:1"
SELECT_TINT="Wybierz Tint2 z listy, po kliknięcu <b>OK</b> wszystkie zaznaczone zostaną uruchomione."
SELECT="Wybór"
TINT_CONF_FILE="plik konfiguracji tint2"
;;
*)
TITLE="Tint2 Panels Manager"
CANCEL="--button=Cancel:1"
SELECT_TINT="Select Tint2s from the list. Click <b>OK</b> to start all selected."
SELECT="Select"
TINT_CONF_FILE="tint2 Name"
;;
esac
########################################################################
tintRunning(){
# make blank tempfile, to save running tint2 paths
TEMPFILE=$(mktemp --tmpdir tint2.XXXX)
pgrep -a tint2 | while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
TPATH=$(echo $cmd | awk '{print $NF}')
echo $TPATH >> $TEMPFILE
fi
done
}
fillArrays(){
num="$1"
tintsPath[$num]="$2" # full filepath to the tint2
tintsArr[$num]="$3" # displayed name
# see if name matches one of the running tints
if grep -qx "$2" "$TEMPFILE";then # if tint2 is running (read from tempfile)
checkArr[$num]="TRUE" # make checkmark in dialog
else
checkArr[$num]="FALSE"
fi
}
findTint(){
# search dirs for tint2 config files
num=0
for x in $(find $TINT2PATH -type f -name *tint2rc);do
# check if likely tint2 config file
pm=$(grep "panel_monitor" "$x")
if [[ $pm ]];then
TINT2=$( echo $x | awk -F"/" '{print $(NF-1)"/"$NF}')
fillArrays $num $x $TINT2
num=$(($num+1))
fi
done
}
# get any commandline arguments
if ! (( $# == 0 ));then
for arg in "$@";do
if [[ $1 = "-h" ]] || [[ $1 = "--help" ]];then
echo -e "$USAGE"
exit 0
else
echo -e "\tERROR: sorry I don't understand the input"
echo -e "$USAGE"
exit 0
fi
done
fi
# get tint2 directories in .tint2, add to array
tintRunning
findTint
# loop through arrays, and build msg text for yad dialog
unset LISTTINT
for ((j=0; j<${#tintsArr[*]}; j++));do
LISTTINT="$LISTTINT ${checkArr[j]} ${tintsArr[j]}"
done
## Populate dialog from array, get return value(s)
RET=$($DLGDEC $WINICON --list --title="$TITLE" \
--text="$SELECT_TINT" \
--checklist --width=350 --height=500 --multiple \
--column="$SELECT" --column="$TINT_CONF_FILE" $LISTTINT --separator=":" \
$CANCEL $OK \
)
if (( $? == 1 )); then # cancel button pressed
exit 0
else
> $SESSIONFILE # Create new session file
# loop through returned choices, add to array
i=0
OIFS=$IFS # copy original IFS
IFS=":" # separator is ":" in returned choices
for name in $RET; do
retTint[$i]=$name
i=$(($i+1))
done
IFS=$OIFS # reset IFS
# kill all tint2s
pgrep -a tint2 | while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
fi
done
for name in ${retTint[*]};do # loop through checkmarked tint2 names
for ((j=0; j<${#tintsPath[*]}; j++));do # traverse through elements
for f in ${tintsPath[j]};do
display=$( echo $f | awk -F"/" '{print $(NF-1)"/"$NF}')
path=$( echo $f | awk -F"/" '{print "/"$(NF-2)"/"$(NF-1)"/"$NF}')
# see if it matches the returned name
if [[ $display = $name ]];then
#DEBUG
#echo "mb-tint2zen: path=$path" >> $DEBUGFILE
#echo "mb-tint2zen: f=$f" >> $DEBUGFILE
#DEBUG_KONIEC
echo -e "$path" >> $SESSIONFILE
tint2 -c "$f" & #start the tint2
sleep 1s
fi
done
done
done
if pgrep picom;then mabox-compositor --restart; fi
fi
rm -r $TEMPFILE
exit 0

75
bin/mbscreenlocker Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/bash
CONFIG_DIR="$HOME/.config/mbscreenlocker"
CONFIG_FILE="$CONFIG_DIR/mbscreenlocker.conf"
# Make config directory if not exist
mkdir -p $CONFIG_DIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Effect to use: dim, blur, dimblur or pixel
effect=dim
# ScreenLocker program: betterlockscreen or i3lock
screenlocker=i3lock
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
case $LANG in
pl*)
TITLE="Tworzenie obrazków dla blokady ekranu"
TEXT="\nCierpliwości...\nto może chwilkę potrwać.."
TITLE2="Gotowe"
TEXT2="\n<b>super+l</b> aby zablokować ekran"
;;
*)
TITLE="Caching images for faster screen locking"
TEXT="\nPlease wait...\nthis might take few seconds..."
TITLE2="Done"
TEXT2="All required changes have been applied.\n Use <b>super + l</b> to lock screen."
;;
esac
lock() {
if [[ $screenlocker == "betterlockscreen" ]]; then
betterlockscreen -l $effect
else
i3lock -B 2 -k --time-color="337d00ff" --date-color="337d00ff"
fi
}
cache() {
source <(grep file ~/.config/nitrogen/bg-saved.cfg)
notify-send.sh -u critical -i emblem-photos -R /tmp/mbscreencache "$TITLE" "$TEXT"
betterlockscreen -u "$file"
notify-send.sh -u normal -i emblem-photos -R /tmp/mbscreencache "$TITLE2" "$TEXT2"
}
setimg() {
img=$(yad --file --file-filter="Image Files (*.jpg *.jpeg *.png *.tif)| *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG")
if [ -f "$img" ]; then
notify-send.sh -u critical -i emblem-photos -R /tmp/mbscreencache "$TITLE" "$TEXT"
betterlockscreen -u "$img"
notify-send.sh -u normal -i emblem-photos -R /tmp/mbscreencache "$TITLE2" "$TEXT2"
fi
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
-c|cache) cache;;
-h|--help) usage;;
-s|setimg) setimg;;
*) lock;;
esac
exit 0

119
bin/mbwallpaper Executable file
View File

@@ -0,0 +1,119 @@
#!/bin/bash
CONFIG_DIR="$HOME/.config/mbwallpaper"
CONFIG_FILE="$CONFIG_DIR/mbwallpaper.conf"
WALLPAPERS_LIST="$CONFIG_DIR/wplist"
# Make config directory if not exist
mkdir -p $CONFIG_DIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Directory with wallpapers
wallpaper_dir=/usr/share/backgrounds/
# Rotate time in seconds
interval=10
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
setter=nitrogen
# decide which setter and command use to set wallpaper
case "$setter" in
nitrogen) command="nitrogen --set-zoom-fill --save";;
feh) command="feh --bg-fill" ;;
pcmanfm) command="pcmanfm -w" ;;
*) echo "Unknown wallpaper setter. Please check your config file $CONFIG_FILE";exit 1;;
esac
#check if wallpaper dir was changed, if so delete wallpaper list
if [ ! -f "$CONFIG_DIR/.lastdir" ]; then
echo "$wallpaper_dir" > "$CONFIG_DIR/.lastdir"
else
lastdir=$(<$CONFIG_DIR/.lastdir)
[[ "$wallpaper_dir" != "$lastdir" ]] && rm "$WALLPAPERS_LIST" && echo "$wallpaper_dir" > "$CONFIG_DIR/.lastdir"
fi
checkwplist() {
# If list does not exist or is empty
if [[ ! -f $WALLPAPERS_LIST || $(wc -l <$WALLPAPERS_LIST) -lt 1 ]]; then
# Prepare list with wallpapers (only PNG and JPG)
ls -1 "$wallpaper_dir"/*{.jpg,.JPG,.jpeg,.JPEG,.png,.PNG,.avif,.AVIF,.webp,.WEBP} > "$WALLPAPERS_LIST"
fi
}
one() {
checkwplist
line=$(shuf -n 1 $WALLPAPERS_LIST)
#delete it from list
grep -v "$line" "$WALLPAPERS_LIST" > "$CONFIG_DIR/tmpfile"; mv "$CONFIG_DIR/tmpfile" "$WALLPAPERS_LIST"
#run command to set wallpaper
${command} ${line}
exit 0
}
choose() {
case $LANG in
pl*)
TITLE="Wybierz tapetę"
TEXT="\n<b>Strzałki</b> / <b>kółko myszy</b> poprzednia/następna.\n<b>Enter</b> by ustawić tapetę.\n<b>Esc</b> by wyjść."
;;
*)
TITLE="Select Wallpaper"
TEXT="\n<b>Arrows</b> / <b>mousewheel</b> prev/next.\n<b>Enter</b> to set wallpaper.\n<b>Esc</b> to quit."
;;
esac
SCREENSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $4}')
W="${SCREENSIZE%x*}"
H="${SCREENSIZE#*x}"
FW=$((W/4))
FH=$((H/4))
X=$((FW*3/2))
Y=$((H-FH-40))
notify-send.sh -t 12000 -i ~/.config/mabox/wpicon.png "$TITLE" "$TEXT"
feh -B "#4D4D4D" -N -x --scale-down -E ${FH} -y ${FW} -^ "Enter=select, Arrows=next/prev Esc=quit" -g ${FW}x${FH}+${X}+${Y} ${wallpaper_dir} -A "${command} '%f'"
}
slideshow() {
while true
do
checkwplist
# if wallpapers list have more than 0 lines
while [ $(wc -l <$WALLPAPERS_LIST) -gt 0 ]
do
# get random line
line=$(shuf -n 1 $WALLPAPERS_LIST)
#delete it from list
grep -v "$line" "$WALLPAPERS_LIST" > "$CONFIG_DIR/tmpfile"; mv "$CONFIG_DIR/tmpfile" "$WALLPAPERS_LIST"
#run command to set wallpaper
${command} ${line}
sleep ${interval}
done
done
}
changedir(){
wdir=${1/$HOME/\~}
#notify-send.sh "dirrrrrrr" "$wdir"
sd "wallpaper_dir=.*$" "wallpaper_dir=${wdir}" ${CONFIG_FILE}
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
-o|one) one;;
-c|choose) choose;;
-h|--help) usage;;
-s) slideshow;;
-d|changedir) changedir "$2";;
esac
exit 0

804
bin/mcc Executable file
View File

@@ -0,0 +1,804 @@
#!/bin/bash
# mcc: Mabox Control Center
# Copyright (C) 2019-2025 napcok <danieln@maboxlinux.org>
#
if hash btop 2>/dev/null; then
BTOP="btop"
else
BTOP="bpytop"
fi
if hash fastfetch 2>/dev/null; then
FETCH="fastfetch"
else
FETCH="neofetch"
fi
case $LANG in
pl*)
TITLE="Centrum Sterowania Mabox"
MCC="<big><b>Centrum Sterowania Mabox</b></big>\t\n<i>Skonfiguruj wygląd i zachowanie swojego Maboxa</i>\t"
START="Start"
SYSTEM="System i Sprzęt"
LOCALE_SETTINGS="Język i formaty"
LANGUAGE_PACKAGES="Pakiety językowe"
KERNEL="Jądro systemowe"
USER_ACCOUNTS="Konta użytkowników"
TIME_DATE="Data i Czas"
KEYBOARD="Mysz i Klawiatura"
HARDWARE="Konfiguracja sprzętowa"
SOFTWARE="Programy"
AUTOSTART="Autostart"
AUTOSTART_HEAD="Autostart"
LOOK="Wygląd"
TINT2="Panel Tint2"
SETTINGS="Ustawienia"
CONKY="Conky"
MENU="Menu/Panele boczne"
THEMES="Motywy"
HELP="Uzyskaj Pomoc"
HELP_TXT="Visit <a href='https://manual.maboxlinux.org/en/'>Mabox Linux Manual</a> to learn more about Mabox. \nDo you have questions? Want to get involved?\nTake a look at our: <a href='https://maboxlinux.org/'>official website</a>, <a href='https://forum.maboxlinux.org/'>forum</a>, <a href='https://blog.maboxlinux.org/'>blog</a>\n \n<i>Mabox Linux is developed with passion in spare time.\nMabox is free and it will always be.\nIf you like Mabox you can help by making a small <a href='https://ko-fi.com/maboxlinux'>donation</a></i> \nThank you for choosing to use Mabox Linux!\n"
SYSTEM_DESC="Ustawienia oraz informacje systemowe i sprzętowe"
MONITORS="<b>Monitor(y)</b>"
SOFTWARE_DESC="Aktualizacja - Instalacja Programów - Preferowane programy\n"
AUTOSTART_DESC="<a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Pomoc (online)</a>\nOpenbox używa dwóch mechanizmów autostartu.\nPierwszy z nich to autostart XDG."
AUTOSTART_DESC2="Drugim - specyficznym dla Openbox - jest skrypt <i><b>~/.config/openbox/autostart</b></i>."
EDIT_XDG="Wybierz programy autostartu XDG"
EDIT_SCRIPT="Edytuj skrypt"
AUTOSTART_RESET="Przywróć domyślny skrypt autostartu"
LOOK_DESC="Narzędzia do konfiguracji wyglądu\n"
EDIT_FILE="Edytuj plik"
TINT_DESC="<b>Konfigurator paneli tint2</b>\nTutaj możesz wybrać konfigurację panelu Tint2.\nW Maboxie dostępne są różne konfiguracje panelu tint2, możesz również dodać własne do katalogu <i>~/.config/tint2</i>."
T_CONF="Konfiguruj panel"
T_CHOOSE="Wybierz tint2!!Możesz uruchomić kilka paneli"
T_RESTART="Restartuj panel(e)"
T_LAUNCHERS="Dodaj/usuń programy do panelu"
TINT_DIR="Otwórz katalog <i>~/.config/tint2/</i> w menadżerze plików"
CONKY_DESC="<b>Menedżer Conky</b><i>(beta)</i>\nWybierz uruchamiane Conky. W Maboxie dostępnych jest kilka konfiguracji Conky, możesz dodać własne do katalogu <i>~/.config/conky</i>."
CONKY_RESTART="Restartuj Conky"
OPEN_CONKYDIR="Otwórz katalog <i>~/.config/conky</i>"
MENU_DESC="Główne menu (<small>wywoływane przez: prawy klik, skrót win+spacja lub z ikony w panelu</small>) umożliwia wyszukiwanie, należy po prostu zacząć pisać np. nazwę programu.\n<small><i>Dostępne są również dwa <b>panele boczne</b>, umożliwiające szybki dostęp np. do systemu plików.</i>\nDo menu oraz paneli możesz dodawać swoje własne polecenia - <a href='https://blog.maboxlinux.org/how-to-add-custom-commands-to-menu-and-sidepanels/'>post na devblogu</a></small>"
M_EDIT_MAIN="Ulubione"
M_EDIT_MAIN_AFTER="Pod Aplikacjami"
M_RESTORE_MAIN="Przywróć domyślne menu"
M_LEFT="<b>PANEL LEWY</b>"
M_LEFT_KEY="<small>(ctrl+super+left)</small>"
M_MAIN="<b>MENU GŁÓWNE</b>"
M_MAIN_KEY="<small>(super)</small>"
SETTINGS_MENU="<b>MENU USTAWIEŃ</b>"
SETTINGS_EDIT="Edytuj..."
M_RIGHT="<b>PANEL PRAWY</b>"
M_RIGHT_KEY="<small>(ctrl+super+left)</small>"
M_LEFT_DESC="<small>Lewy panel\n - szybka nawigacja po systemie plików\n - zakładki GTK\n - maszyny wirtualne</small>"
M_RIGHT_DESC="<small>Prawy panel\n - ustawienia systemowe\n - pomoc\n - wyjście</small>"
M_CUSTOMIZE="<i>Edytuj komendy:</i>"
M_MORE="<b>WIĘCEJ USTAWIEŃ...</b>"
M_COLORSETTINGS="<b>Kolorystyka...</b>"
OWN_COMMANDS_TOP="(Góra)"
OWN_COMMANDS_BOTTOM="(Dół)"
COMPOSITOR="Kompozytor"
COMP_DESC="Menadżerem kompozycji w Maboxie jest <b>Picom</b> - fork Compton.\nSkrót klawiszowy do włączania/wyłączania menadżera kompozycji to (<b>win</b>+<b>p</b>).\n\nMabox dostarcza kilku plików konfiguracyjnych dla Picoma.\nMożesz je łatwo przełączać za pomocą Manadżera Picom."
COMP_GUI="Ustawienia"
COMP_EDIT="Menadżer Picom"
COMP_RESTART="Restart"
COMP_TOGGLE="Włącz/Wyłącz (<b>win</b>+<b>p</b>)"
COMP_DIR="Otwórz katalog z konfiguracjami Picom"
MT_MNGR="Menedżer Motywów Maboxa"
MT_MNGR_DESC="\n<a href='https://manual.maboxlinux.org/en/configuration/theme-manager/'>Pomoc (online)</a>\nMotyw Maboxa składa się z:\n - tapety\n - wystroju GTK2/GTK3 oraz obramowania okien Openboxa\n - ustawień panelu Tint2\n - uruchamianych automatycznie Conky \n\nZa pomocą menedżera motywów możesz w wygodny sposób zapisywać swoje konfiguracje, a następnie dowolnie przełączać się między nimi."
COLORIZER_DESC="<b>Colorizer</b>\nUmożliwia zmianę kolorystyki elementów pulpitu Mabox.\nMoże również automatycznie generować kolorystykę na bazie tapety.\n<i>Zobacz video (online):</i> <a href='https://youtu.be/h50oeS7aFyM'>Colorizer - krótki przegląd</a>\n"
COL_MODULES="Moduły Główne"
COL_ADDONS="<i>dodatki:</i>"
COL_MENU="Colorizer RootMenu"
LNG="pl"
USER_LBL="użytkownik"
USERS_MSM="Użytkownicy"
RES="rozdzielczość"
PKGS_INSTALLED="zainstalowane pakiety"
PKGS_STAT="Statystyki"
UPDCHECK="sprawdź aktualizacje"
CLI_UPD="Aktualizacja CLI"
KERNEL_LBL="jądro"
KERNELS="Jądra"
INSTALLED="zainstalowany:"
DAYS_AGO="dni temu"
MABOX_DESC="Twój lekki, szybki i funkcjonalny Linuksowy Desktop"
ADVANCED="Zaawansowane"
FONTS="Czcionki"
FONT_DESC="<b>Czcionki</b>\nUżuj Menu Konfiguracji Czcionek aby ustawić czcionki dla:\n - Openbox - tytuł okna\n - Menu i Panele Boczne\n - czcionka GTK\n - Conky"
FONT_MENU="Menu Konfiguracji Czcionek"
FONT_INC="Powiększ Wszystkie"
FONT_DEC="Pomniejsz Wszystkie"
FONT_RESET="Resetyj Wszystkie"
WALLPAPER="Tapety"
WALLPAPER_DESC="<b>Jak ustawić tapetę w Maboxie?</b>\n\nCzy widzisz ikonę z obrazkiem w panelu?\nKliknij w nią prawym przyciskiem myszy...\n"
WP_RANDOM="Losowa tapeta"
WP_CHOOSE="Wybierz w menadżerze plików"
WP_PREVIEW="Przeglądaj i wybierz"
WP_SLIDE="Pokaz slajdów"
WP_GENERATE="Generator tapet"
WP_DIRS="Edytuj katalogi z tapetami"
WP_TITLE="Jak ustawić tapetę w Maboxie?"
WP_MSG="\nKlikając prawym przyciskiem myszy w ikonę w panelu masz kilka sposobów ustawienia tapety:\n- <b>losowa</b>,\n- <b>wybierz</b> <i>(z menu kontekstowego w menadżerze plików)</i>,\n- <b>przeglądaj i wybierz</b>,\n- <b>pokaz slajdów</b>\n- lub <b>generator</b> tapet\n\nNa dole menu możesz ustawić akcję dla lewego kliknięcia w ikonę.\n\nWypróbuj różne opcje i ustaw tą, która najbardziej Ci pasuje."
;;
es*)
TITLE="Centro de control Mabox"
MCC="<big><b>Centro de control Mabox</b></big>\t\nConfigura y ajusta tu sistema Mabox\t"
START="Start"
SYSTEM="Sistema/Hardware"
LOCALE_SETTINGS="Configuración regional"
LANGUAGE_PACKAGES="Paquetes de idiomas"
KERNEL="Núcleo"
USER_ACCOUNTS="Cuentas de usuario"
TIME_DATE="Hora y fecha"
KEYBOARD="Mouse e teclado"
HARDWARE="Configuración de hardware"
SOFTWARE="Programas"
AUTOSTART="Programas de inicio"
AUTOSTART_HEAD="Programas de inicio"
LOOK="Apariencia"
TINT2="Panel Tint2"
SETTINGS="Ajustes"
CONKY="Recuadro Conky"
MENU="Menú y Paneles"
THEMES="Temas"
HELP="Get Help"
HELP_TXT="Visit <a href='https://manual.maboxlinux.org/es/'>Mabox Linux Manual</a> to learn more about Mabox. \nDo you have questions? Want to get involved?\nTake a look at our: <a href='https://maboxlinux.org/'>official website</a>, <a href='https://forum.maboxlinux.org/'>forum</a>, <a href='https://blog.maboxlinux.org/'>blog</a>\n \n<i>Mabox Linux is developed with passion in spare time.\nMabox is free and it will always be.\nIf you like Mabox you can help by making a small <a href='https://ko-fi.com/maboxlinux'>donation</a></i> \nThank you for choosing to use Mabox Linux!\n"
SYSTEM_DESC="Ajustes e información del sistema y de hardware"
MONITORS="<b>Monitor(es)</b>"
SOFTWARE_DESC="Instalación y actualización de programas - Aplicaciones preferidas.\n"
AUTOSTART_DESC="<a href='https://manual.maboxlinux.org/es/configuration/autostart/'>Info (online)</a>\nOpenbox ocupa 2 métodos de reinicio.\nEl primero es reinicio por XDG."
AUTOSTART_DESC2="El segundo método de reinicio es usar el mismo archivo script de Openbox:\n<i><b>~/.config/openbox/autostart</b></i>. "
EDIT_XDG="Seleccionar ítemes para reinicio"
EDIT_SCRIPT="Editar el archivo script de reinicio"
AUTOSTART_RESET="Reestablecer el archivo script de reinicio por defecto"
LOOK_DESC="Configurar la apariencia de tu escritorio.\n"
EDIT_FILE="Editar el archivo"
TINT_DESC="<b>Configurador de paneles Tint2</b>\nAquí puede elegir los ajustes para los paneles.\nExisten varios ajustes predefinidos en Mabox, y además puede agregar nuevos en este directorio <i>~/.config/tint2</i> ."
T_CONF="Configurar panel"
T_CHOOSE="Elija un panel tint2!!Puede ejecutar varios paneles de inmediato"
T_RESTART="Reiniciar panel tint2"
T_LAUNCHERS="Add/remove launchers..."
TINT_DIR="Abrir la carpeta <i>~/.config/tint2/</i> "
CONKY_DESC="<b>Conky (on steroids)</b>\nConky in Mabox has been equipped with additional powers not available in any other Linux distribution!\n\nRight click on any Conky to see handy context menu... <i>try it now!</i>\n\nYou can also define your own left-click command (or a multi-command menu)."
CONKY_RESTART="Recargar recuadro Conky"
OPEN_CONKYDIR="Abrir la carpeta <i>~/.config/conky</i> "
MENU_DESC="Menu principal (<small>accede con clic derecho, teclas Super+barra de espacio o desde el ícono del panel</small>) activa escribe sobre buscar. Sólo empieza a escribir el término que estas buscando.\n<small><i>There are also two <b>side-panels</b> available for quick access to file system locations for example.</i>You can add custom commands to menus and side-panels - <a href='https://blog.maboxlinux.org/how-to-add-custom-commands-to-menu-and-sidepanels/'>blogpost</a></small>"
M_EDIT_MAIN="Favoritos"
M_EDIT_MAIN_AFTER="Below Apps"
M_RESTORE_MAIN="Reestablecer el menu por defecto"
M_LEFT="<b>PANEL IZQUIERDO</b>"
M_LEFT_KEY="<small>(ctrl+super+left)</small>"
M_MAIN="<b>MENU PRINCIPAL</b>"
M_MAIN_KEY="<small>(super)</small>"
SETTINGS_MENU="<b>SETTINGS MENU</b>"
SETTINGS_EDIT="Editar..."
M_RIGHT="<b>PANEL DERECHO</b>"
M_RIGHT_KEY="<small>(ctrl+super+right)</small>"
M_LEFT_DESC="<small>Panel izquierdo\n - Navegacion veloz\n - Marcadores GTK\n - Máquinas Virtuales</small>"
M_RIGHT_DESC="<small>Panel derecho\n - Configuración del sistema\n - ayuda\n - opciones de salida</small>"
M_CUSTOMIZE="<i>Ajustes:</i>"
M_MORE="<b>MORE SETTINGS..</b>"
M_COLORSETTINGS="<b>Coloring...</b>"
OWN_COMMANDS_TOP="(TOP)"
OWN_COMMANDS_BOTTOM="(BOTTOM)"
COMPOSITOR="Compositor gráfico"
COMP_DESC="<b>Picom</b> is used as composite manager in Mabox.\n\nWith the Picom Manager you can choose which of the several available configurations you want to use. You can also add your own.\n\n"
COMP_GUI="Configuración"
COMP_EDIT="Picom Manager"
COMP_RESTART="Reiniciar compositor gráfico"
COMP_TOGGLE="Activar/desactivar compositor (<b>win</b>+<b>p</b>)"
COMP_DIR="Open Picom config directory"
MT_MNGR="Gestor de Temas Mabox"
MT_MNGR_DESC="\n<a href='https://manual.maboxlinux.org/es/configuration/theme-manager/'>Help (online)</a>\nTemas Mabox consiste de:\n - fondos de pantalla\n - temas GTK2/GTK3\n - ajustes a tema Openbox\n - paneles Tint2 seleccionados\n - recuadros Conky seleccionados\n\nCon el gestor de Temas en Mabox puede fácilmente guardar nuevas configuraciones, y cambiar entre ellas."
COLORIZER_DESC="<b>Colorizer</b>\nColorizer allows you to change the color of the Mabox desktop elements.\nIt can also generate themes based on the wallpaper colors or monochrome themes from color picked from screen.\n"
COL_MODULES="Core Modules:"
COL_ADDONS="<i>addons:</i>"
COL_MENU="Colorizer RootMenu"
LNG="en"
USER_LBL="user"
USERS_MSM="Users"
RES="resolution"
PKGS_INSTALLED="installed pkgs"
PKGS_STAT="Statistics"
UPDCHECK="check updates"
CLI_UPD="CLI update"
KERNEL_LBL="kernel"
KERNELS="Kernels"
INSTALLED="install date: "
DAYS_AGO="days ago"
MABOX_DESC="Your fast, lightweight and functional Linux Desktop"
ADVANCED="Advanced"
FONTS="Fonts"
FONT_DESC="<b>Fonts</b>\nUse Font Config Menu to set fonts for:\n - Openbox window title\n - Menus and Side panels\n - GTK font\n - Conkies"
FONT_MENU="Font Config Menu"
FONT_INC="Increase All"
FONT_DEC="Decrease All"
FONT_RESET="Reset All"
WALLPAPER="Wallpaper"
WALLPAPER_DESC="<b>How to set Wallpaper in Mabox?</b>\n\nDo you see an icon with a picture in the tint2 panel?\nRight-click on it...\n"
WP_RANDOM="Random wallpaper"
WP_CHOOSE="Choose from file manager"
WP_PREVIEW="Preview &amp; choose"
WP_SLIDE="Slideshow"
WP_GENERATE="Generate"
WP_DIRS="Edit Wallpapers Dirs"
WP_TITLE="How to set Wallpaper in Mabox?"
WP_MSG="\nFrom right-click on icon in panel you have access to several ways to set the wallpaper:\n- <b>random</b>,\n- <b>choose</b> <i>(using context menu in filemanager)</i>,\n- <b>preview and set</b>,\n- <b>slideshow</b>\n- or <b>generate</b>\n\nAt the bottom of the menu you have the option to assign the desired action to the left-click on the icon on the panel.\n\nTest different options and assign the one that suits you best."
;;
*)
TITLE="Mabox Control Center"
MCC="<big><b>Mabox Control Center</b></big>\t\n<i>Configure and customize your Mabox Linux</i>\t"
START="Start"
SYSTEM="System/HW"
LOCALE_SETTINGS="Locale Settings"
LANGUAGE_PACKAGES="Language Packages"
KERNEL="Kernel"
USER_ACCOUNTS="User Accounts"
TIME_DATE="Time and Date"
KEYBOARD="Mouse and Keyboard Settings"
HARDWARE="Hardware Configuration"
SOFTWARE="Software"
AUTOSTART="Autostart"
AUTOSTART_HEAD="Autostart"
LOOK="Look and Feel"
TINT2="Tint2 Panel"
SETTINGS="Settings"
CONKY="Conky"
MENU="Menu/SidePanels"
THEMES="Themes"
HELP="Get Help"
HELP_TXT="Visit <a href='https://manual.maboxlinux.org/en/'>Mabox Linux Manual</a> to learn more about Mabox. \nDo you have questions? Want to get involved?\nTake a look at our: <a href='https://maboxlinux.org/'>official website</a>, <a href='https://forum.maboxlinux.org/'>forum</a>, <a href='https://blog.maboxlinux.org/'>blog</a>\n \n<i>Mabox Linux is developed with passion in spare time.\nMabox is free and it will always be.\nIf you like Mabox you can help by making a small <a href='https://ko-fi.com/maboxlinux'>donation</a></i> \nThank you for choosing to use Mabox Linux!\n"
SYSTEM_DESC="System and Hardware settings and information"
MONITORS="<b>Monitor(s)</b>"
SOFTWARE_DESC="Software installation and update - Preferred Applications.\n"
AUTOSTART_DESC="<a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Info (online)</a>\nOpenbox uses two autostart methods.\nFirst is XDG autostart."
AUTOSTART_DESC2="Second method is Openbox own autostart script: <i><b>~/.config/openbox/autostart</b></i>. "
EDIT_XDG="Select items to autostart"
EDIT_SCRIPT="Edit script"
AUTOSTART_RESET="Reset to default autostart script"
LOOK_DESC="Customize Look and Feel of your desktop.\n"
EDIT_FILE="Edit file"
TINT_DESC="<b>Tint2 panels Configurator</b>\nHere you can choose Tint2 panel(s) configuration.\nThere are some predefined configurations in Mabox, you can also add your own to <i>~/.config/tint2</i> directory."
T_CONF="Configure panel"
T_CHOOSE="Choose tint2!!You can run several tint2 panels at once"
T_RESTART="Restart tint2"
T_LAUNCHERS="Add/remove launchers..."
TINT_DIR="Open <i>~/.config/tint2/</i> directory "
CONKY_DESC="<b>Conky (on steroids)</b>\nConky in Mabox has been equipped with additional powers not available in any other Linux distribution!\n\nRight click on any Conky to see handy context menu... <i>try it now!</i>\n\nYou can also define your own left-click command (or a multi-command menu)."
CONKY_RESTART="Reload Conky"
OPEN_CONKYDIR="Open <i>~/.config/conky</i> directory"
MENU_DESC="Main menu (<small>access it by right click, win+space shortcut or from panel icon</small>) have type to search functionality. Just start to type what you looking for.\n<small><i>There are also two <b>side-panels</b> available for quick access to file system locations for example.</i> You can add custom commands to menus and side-panels <a href='https://blog.maboxlinux.org/how-to-add-custom-commands-to-menu-and-sidepanels/'>blogpost</a></small>"
M_EDIT_MAIN="Edit Favorites"
M_EDIT_MAIN_AFTER="Edit below Apps"
M_RESTORE_MAIN="Reset mainmenu to default"
M_LEFT="<b>LEFT PANEL</b>"
M_LEFT_KEY="<small>(ctrl+super+left)</small>"
M_MAIN="<b>MAIN MENU</b>"
M_MAIN_KEY="<small>(super)</small>"
SETTINGS_MENU="<b>SETTINGS MENU</b>"
SETTINGS_EDIT="Edit..."
M_RIGHT="<b>RIGHT PANEL</b>"
M_RIGHT_KEY="<small>(ctrl+super+right)</small>"
M_LEFT_DESC="<small>Left panel\n - quick navigation\n - GTK Bookmarks\n - Virtualbox machines</small>"
M_RIGHT_DESC="<small>Right panel\n - system settings\n - help\n - exit options</small>"
M_CUSTOMIZE="<i>Customize commands:</i>"
M_MORE="<b>MORE SETTINGS..</b>"
M_COLORSETTINGS="<b>Coloring...</b>"
OWN_COMMANDS_TOP="(TOP)"
OWN_COMMANDS_BOTTOM="(BOTTOM)"
COMPOSITOR="Compositor"
COMP_DESC="<b>Picom</b> is used as composite manager in Mabox.\n\nWith the Picom Manager you can choose which of the several available configurations you want to use. You can also add your own.\n\n"
COMP_EDIT="Picom Manager"
COMP_RESTART="Restart"
COMP_TOGGLE="Toggle (<b>win</b>+<b>p</b>)"
COMP_DIR="Open Picom config directory"
MT_MNGR="Mabox Theme Manager"
MT_MNGR_DESC="\n<a href='https://manual.maboxlinux.org/en/configuration/theme-manager/'>Help (online)</a>\nMabox theme consist of:\n - wallpaper\n - GTK2/GTK3 Theme and Openbox window decoration \n - selected Tint2 panel(s)\n - selected Conkies \n\nWith Mabox Theme Manager you can easily save your configurations, and switch between them."
COLORIZER_DESC="<b>Colorizer</b>\nColorizer allows you to change the color of the Mabox desktop elements.\nIt can also generate themes based on the wallpaper colors or monochrome themes from color picked from screen.\n"
COL_MODULES="Core Modules:"
COL_ADDONS="<i>addons:</i>"
COL_MENU="Colorizer RootMenu"
LNG="en"
USER_LBL="user"
USERS_MSM="Users"
RES="resolution"
PKGS_INSTALLED="installed pkgs"
PKGS_STAT="Statistics"
UPDCHECK="check updates"
CLI_UPD="CLI update"
KERNEL_LBL="kernel"
KERNELS="Kernels"
INSTALLED="install date: "
DAYS_AGO="days ago"
MABOX_DESC="Your fast, lightweight and functional Linux Desktop"
ADVANCED="Advanced"
FONTS="Fonts"
FONT_DESC="<b>Fonts</b>\nUse Font Config Menu to set fonts for:\n - Openbox window title\n - Menus and Side panels\n - GTK font\n - Conkies"
FONT_MENU="Font Config Menu"
FONT_INC="Increase All"
FONT_DEC="Decrease All"
FONT_RESET="Reset All"
WALLPAPER="Wallpaper"
WALLPAPER_DESC="<b>How to set Wallpaper in Mabox?</b>\n\nDo you see an icon with a picture in the tint2 panel?\nRight-click on it...\n"
WP_RANDOM="Random wallpaper"
WP_CHOOSE="Choose from file manager"
WP_PREVIEW="Preview &amp; choose"
WP_SLIDE="Slideshow"
WP_GENERATE="Generate"
WP_DIRS="Edit Wallpapers Dirs"
WP_TITLE="How to set Wallpaper in Mabox?"
WP_MSG="\nFrom right-click on icon in panel you have access to several ways to set the wallpaper:\n- <b>random</b>,\n- <b>choose</b> <i>(using context menu in filemanager)</i>,\n- <b>preview and set</b>,\n- <b>slideshow</b>\n- or <b>generate</b>\n\nAt the bottom of the menu you have the option to assign the desired action to the left-click on the icon on the panel.\n\nTest different options and assign the one that suits you best."
;;
esac
OSNAME=$(lsb_release -d | awk '{print $2}')
OSVERSION=$(lsb_release -r | awk '{print $2}')
#OSCODE=$(lsb_release -c | awk '{print $2}')
OSCODE=$(grep CODENAME /etc/lsb-release |cut -d '=' -f2)
# system uptime
UPT="$(uptime -p)"
UPT="${UPT/up /}"
UPT="${UPT/ day?/d}"
UPT="${UPT/ hour?/h}"
UPT="${UPT/ minute?/m}"
# install date
# Days ago
INST=$(stat -c %W /)
INSTDATE=$(stat -c %w /|awk '{print $1}')
TODAY=$(date +%s)
DIFF=$(( (TODAY - INST) / 86400 ))
if [[ "$DIFF" > "1" ]];then
DAGO="(${DIFF} ${DAYS_AGO})"
else
DAGO=""
fi
PKGS=$(pacman -Qq 2>/dev/null | wc -l)
# kernel version
KERN="${KERN:-$(uname -sr | awk '{print $2}')}"
KERN="${KERN/-*/}"
KERN="${KERN/linux/}"
KERN="${KERN,,}"
RESOLUTION=$(xdpyinfo | awk '/^ +dimensions/ {print $2}')
INTRO_TXT=$(cat <<EOF
\t<big>Mabox Linux $OSVERSION</big> <i>$OSCODE</i>
\t<small><i>$MABOX_DESC</i></small>\n
\t<small><tt>$INSTALLED </tt></small><b>$INSTDATE</b> <small>$DAGO</small>
\t<small><tt>wm: </tt></small><b>$XDG_SESSION_DESKTOP</b>
\t<small><tt>uptime: </tt></small><b>$UPT</b>
\n
EOF
)
maindialog () {
KEY=$RANDOM
res1=$(mktemp --tmpdir mcc-tab1.XXXXXXXX)
res2=$(mktemp --tmpdir mcc-tab2.XXXXXXXX)
res3=$(mktemp --tmpdir mcc-tab3.XXXXXXXX)
res4=$(mktemp --tmpdir mcc-tab4.XXXXXXXX)
res5=$(mktemp --tmpdir mcc-tab5.XXXXXXXX)
res6=$(mktemp --tmpdir mcc-tab6.XXXXXXXX)
res7=$(mktemp --tmpdir mcc-tab7.XXXXXXXX)
res8=$(mktemp --tmpdir mcc-tab8.XXXXXXXX)
res9=$(mktemp --tmpdir mcc-tab9.XXXXXXXX)
res10=$(mktemp --tmpdir mcc-tab10.XXXXXXXX)
res11=$(mktemp --tmpdir mcc-tab11.XXXXXXXX)
res12=$(mktemp --tmpdir mcc-tab12.XXXXXXXX)
if [[ -d "$HOME/.config/blob" ]];then
res13=$(mktemp --tmpdir mcc-tab13.XXXXXXXX)
fi
out=$(mktemp --tmpdir mcc-out.XXXXXXXX)
# cleanup
trap "rm -f $res1 $res2 $res3 $res4 $res5 $res6 $res7 $res8 $res9 $res10 $res11 $res12 $res13 $out" EXIT
#INTRO
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=1 --borders=10 \
--text="$INTRO_TXT" --image=/usr/share/icons/hicolor/128x128/apps/mbcc.png \
--columns=4 --form \
--field="$USER_LBL:LBL" "" \
--field="$PKGS_INSTALLED:LBL" "" \
--field="$UPDCHECK:LBL" "" \
--field="$KERNEL_LBL:LBL" "" \
--field="$RES:LBL" "" \
--field="<b>$USER</b>:LBL" "" \
--field="<b>$PKGS</b>:LBL" "" \
--field="<b>>>></b>:LBL" "" \
--field="<b>$KERN</b>:LBL" "" \
--field="<b>$RESOLUTION</b>:LBL" "" \
--field=" $USERS_MSM!system-config-users!:FBTN" "manjaro-settings-manager -m msm_users" \
--field=" Pamac!package-manager-icon!:FBTN" "pamac-manager" \
--field=" Pamac updater!software-update!:FBTN" "pamac-manager --updates" \
--field=" $KERNELS!distributor-logo-linux!:FBTN" "manjaro-settings-manager -m msm_kernel" \
--field=" ARandr!system-terminal!:FBTN" "arandr" \
--field=" :LBL" "" \
--field=" $PKGS_STAT (<small><tt>yay -Ps</tt></small>)!utilities-terminal!:FBTN" "terminator -T 'Package stats' -e 'yay -Ps;read'" \
--field=" $CLI_UPD (<small><tt>yay</tt></small>)!utilities-terminal!:FBTN" "terminator -e 'bash -c yay;read'" \
--field=" :LBL" "" \
--field=" LXRandr!system-terminal!:FBTN" "lxrandr" \
> $res1 &
# TINT2
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=2 --borders=20 \
--text="$TINT_DESC \n" --image=tint2conf \
--columns=1 --form \
--field="$T_LAUNCHERS:FBTN" "jgtint2launcher" \
--field="$T_CONF:FBTN" "jgtint2-pipe -s" \
--field="$T_RESTART:FBTN" "mb-tint2restart" \
--field="$ADVANCED:LBL" "" \
--field="$T_CHOOSE:FBTN" "mb-tint2-manager" \
--field="$TINT_DIR:FBTN" "exo-open $HOME/.config/tint2/" \
> $res2 &
# MENU
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=3 --borders=1 \
--text="$MENU_DESC" --image=menu-editor \
--columns=4 --form \
--field="$M_LEFT:FBTN" "mb-jgtools places" \
--field="$M_LEFT_KEY:LBL" "" \
--field="$M_CUSTOMIZE:LBL" "" \
--field="$OWN_COMMANDS_TOP:FBTN" "xdg-open $HOME/.config/mabox/places-prepend.csv" \
--field="$OWN_COMMANDS_BOTTOM:FBTN" "xdg-open $HOME/.config/mabox/places-append.csv" \
--field=" :LBL" "" \
--field="$M_MORE:FBTN" "jgmenusettings-pipe -s" \
--field=" $M_COLORSETTINGS!colorizer!:FBTN" "colorizer-menus -s" \
--field="$M_MAIN:FBTN" "mb-jgtools main" \
--field="$M_MAIN_KEY:LBL" "" \
--field=" :LBL" "" \
--field="$M_EDIT_MAIN:FBTN" "xdg-open $HOME/.config/mabox/favorites.csv" \
--field="$M_EDIT_MAIN_AFTER:FBTN" "xdg-open $HOME/.config/mabox/mainmenu_below_apps.csv" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field="$SETTINGS_MENU:FBTN" "mb-jgtools settings" \
--field="<small>(super+s)</small>:LBL" "" \
--field=" :LBL" "" \
--field="$SETTINGS_EDIT:FBTN" "xdg-open $HOME/.config/mabox/settings.csv" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field="$M_RIGHT:FBTN" "mb-jgtools right" \
--field="$M_RIGHT_KEY:LBL" "" \
--field=" :LBL" "" \
--field="$OWN_COMMANDS_TOP:FBTN" "xdg-open $HOME/.config/mabox/right-prepend.csv" \
--field="$OWN_COMMANDS_BOTTOM:FBTN" "xdg-open $HOME/.config/mabox/right-append.csv" \
--field=" :LBL" "" \
--field=" :LBL" "" \
> $res3 &
#--field="$M_LEFT_DESC:LBL" "" \
#--field="$M_RIGHT_DESC:LBL" "" \
# WALLPAPERS
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=4 --borders=20 \
--text="$WALLPAPER_DESC \n" --image="$HOME/.config/mabox/wpicon.png" \
--columns=2 --form \
--field="INFO:FBTN" "notify-send.sh -t 12000 --icon=$HOME/.config/mabox/wpicon.png '$WP_TITLE' '$WP_MSG' " \
--field="$WP_RANDOM:FBTN" "mbwallpaper -o" \
--field="$WP_CHOOSE:FBTN" "pcmanwp" \
--field="$WP_PREVIEW:FBTN" "mbwallpaper -c" \
--field=" :LBL" "" \
--field="$WP_SLIDE:FBTN" "run_wallpaperslideshow" \
--field="$WP_GENERATE:FBTN" "jgwallpapergenerate -s" \
--field="$WP_DIRS:FBTN" "xdg-open $HOME/.config/mabox/wallp_dirs.conf" \
> $res4 &
# CONKY
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=5 --borders=20 \
--text="$CONKY_DESC \n" --image=conky \
--form \
--field=" Conky Manager!colorizer!:FBTN" "colorizer-conky -s" \
--field="$ADVANCED :LBL" "" \
--field="$OPEN_CONKYDIR:FBTN" "exo-open $HOME/.config/conky/" \
> $res5 &
# FONTS
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=6 --borders=20 \
--text="$FONT_DESC \n" --image=font \
--form \
--field="$FONT_MENU!colorizer!:FBTN" "colorizer-fonts -s" \
--field=" :LBL" "" \
--field="$FONT_INC :FBTN" "fontctl inc_all" \
--field="$FONT_DEC :FBTN" "fontctl dec_all" \
--field="$FONT_RESET :FBTN" "fontctl resetall" \
> $res6 &
# Picom
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=7 --borders=20 \
--text="$COMP_DESC" --image=compton \
--columns=1 --form \
--field="$COMP_EDIT:FBTN" "jgpicom-pipe -s" \
--field="$COMP_RESTART:FBTN" "mabox-compositor --restart" \
--field="$COMP_TOGGLE:FBTN" "compton_toggle" \
--field=" :LBL" "" \
--field="$COMP_DIR:FBTN" "exo-open $HOME/.config/picom/configs/" \
> $res7 &
#--field="$COMP_REMOVE:FBTN" "rm -f $HOME/.config/picom.conf" \
#--field="$COMP_DEFAULT:FBTN" "cp /etc/skel/.config/picom.conf $HOME/.config/" \
# COLORIZER
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=8 --borders=20 \
--text="$COLORIZER_DESC" --image=colorizer \
--form \
--columns=2 \
--field=" Colorizer!colorizer!:FBTN" "ycolorizer" \
--field="$COL_MODULES :LBL" "" \
--field="OpenBox:FBTN" "colorizer-ob -s" \
--field="Conky Manager:FBTN" "colorizer-conky -s" \
--field="Menu/SidePanels:FBTN" "colorizer-menus -s" \
--field="Fonts:FBTN" "colorizer-fonts -s" \
--field="Picom:FBTN" "jgpicom-pipe -s" \
--field=" :LBL" "" \
--field="$COL_MENU:FBTN" "colorizer -s" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field="$COL_ADDONS :LBL" "" \
--field="PyRadio:FBTN" "colorizer-pyradio -s" \
--field="Cava:FBTN" "colorizer-cava -s" \
--field=" :LBL" "" \
> $res8 &
# AUTOSTART
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=9 --borders=20 --uri-handler=xdg-open \
--text="<b>$AUTOSTART_HEAD</b>" --image=gtk-execute \
--columns=1 --form \
--field="$AUTOSTART_DESC:LBL" "" \
--field="$EDIT_XDG:FBTN" "yautostart" \
--field="$AUTOSTART_DESC2 :LBL" "" \
--field="$EDIT_SCRIPT <i>~/.config/openbox/autostart</i>:FBTN" "xdg-open $HOME/.config/openbox/autostart" \
--field="$AUTOSTART_RESET:FBTN" "cp /etc/skel/.config/openbox/autostart $HOME/.config/openbox/" \
> $res9 &
# SYSTEM_SPRZET
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=10 --borders=0 --text="$SYSTEM_DESC" --columns=2 --align="center" --form --scroll \
--field="<b>$SETTINGS</b>:LBL" " " \
--field="$LOCALE_SETTINGS:FBTN" "manjaro-settings-manager -m msm_locale" \
--field="$LANGUAGE_PACKAGES:FBTN" "manjaro-settings-manager -m msm_language_packages" \
--field="$KERNEL:FBTN" "manjaro-settings-manager -m msm_kernel" \
--field="$USER_ACCOUNTS:FBTN" "manjaro-settings-manager -m msm_users" \
--field="$TIME_DATE:FBTN" "manjaro-settings-manager -m msm_timedate" \
--field="$KEYBOARD:FBTN" "lxinput" \
--field="$HARDWARE:FBTN" "manjaro-settings-manager -m msm_mhwd" \
--field="$MONITORS:LBL" "" \
--field="ARandr:FBTN" "arandr" \
--field="LXRandR:FBTN" "lxrandr" \
--field=" :LBL" "" \
--field="<b>Info</b>:LBL" "" \
--field=" inxi -CGAD!utilities-terminal!:FBTN" "terminator -T 'inxi -CAGD system info' -e 'inxi -CGAD;bash'" \
--field=" $FETCH!utilities-terminal!:FBTN" "terminator -e '$FETCH;bash'" \
--field=" btop!utilities-terminal!:FBTN" "terminator -T 'btop' -x $BTOP" \
> $res10 &
# WYGLĄD
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=11 --borders=20 --text="$LOOK_DESC" --icons --read-dir=/usr/share/mcc/appearance --item-width=80 \
> $res11 &
# HELP
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=12 \
--image=/usr/share/icons/hicolor/128x128/apps/distributor-logo-mabox-trans.png --text-justify=center --uri-handler=xdg-open --text="$HELP_TXT" \
--form --columns="4" \
--field="www:FBTN" "xdg-open https://maboxlinux.org" \
--field="forum:FBTN" "xdg-open https://forum.maboxlinux.org" \
--field="manual:FBTN" "xdg-open https://manual.maboxlinux.org/en/" \
--field="donate:FBTN" "xdg-open https://ko-fi.com/maboxlinux" \
> $res12 &
if [[ -d "$HOME/.config/blob" ]];then
# MOTYWY
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=13 --borders=20 --uri-handler=xdg-open \
--text="<b>$MT_MNGR</b>\n $MT_MNGR_DESC" \
--form --field="$MT_MNGR!preferences-desktop-theme:FBTN" "mb-obthemes" \
> $res13 &
fi
#main window
if [[ -d "$HOME/.config/blob" ]];then
GDK_BACKEND=x11 yad --window-icon=mcc \
--notebook --tab-pos="left" --key=$KEY \
--tab="$START" \
--tab="$TINT2"\
--tab="$MENU" \
--tab="$WALLPAPER" \
--tab="$CONKY" \
--tab="$FONTS" \
--tab="$COMPOSITOR" \
--tab="Colorizer" \
--tab="$AUTOSTART" \
--tab="$SYSTEM" \
--tab="<i>$LOOK</i>" \
--tab="$HELP"\
--tab="<i>$THEMES</i>" \
--title="$TITLE" --image=/usr/share/icons/hicolor/48x48/apps/mcc.png \
--width="720" --height="420" --image-on-top --text-justify=right --text="$MCC" --no-buttons > $out &
else
GDK_BACKEND=x11 yad --window-icon=mcc \
--notebook --tab-pos="left" --key=$KEY \
--tab="$START" \
--tab="$TINT2"\
--tab="$MENU" \
--tab="$WALLPAPER" \
--tab="$CONKY" \
--tab="$FONTS" \
--tab="$COMPOSITOR" \
--tab="Colorizer" \
--tab="$AUTOSTART" \
--tab="$SYSTEM" \
--tab="<i>$LOOK</i>" \
--tab="$HELP"\
--title="$TITLE" --image=/usr/share/icons/hicolor/48x48/apps/mcc.png \
--width="720" --height="420" --image-on-top --text-justify=right --text="$MCC" --no-buttons > $out &
fi
}
labdialog() {
LABWC_VER=$(labwc -v|awk '{print $2}')
INTRO_TXT=$(cat <<EOF
\t<big>Mabox Linux $OSVERSION</big> <i>$OSCODE</i>
\t<small><i>$MABOX_DESC</i></small>\n
\t<small><tt>$INSTALLED </tt></small><b>$INST</b> <small>$DAGO</small>
\t<small><tt>wm: </tt></small><b>labwc</b><small> (ver. $LABWC_VER)</small>
\t<small><tt>uptime: </tt></small><b>$UPT</b>
\n
EOF
)
KEY=$RANDOM
res1=$(mktemp --tmpdir mcc-tab1.XXXXXXXX)
res2=$(mktemp --tmpdir mcc-tab2.XXXXXXXX)
res3=$(mktemp --tmpdir mcc-tab3.XXXXXXXX)
res4=$(mktemp --tmpdir mcc-tab4.XXXXXXXX)
res5=$(mktemp --tmpdir mcc-tab5.XXXXXXXX)
res6=$(mktemp --tmpdir mcc-tab6.XXXXXXXX)
res7=$(mktemp --tmpdir mcc-tab7.XXXXXXXX)
out=$(mktemp --tmpdir mcc-out.XXXXXXXX)
# cleanup
trap "rm -f $res1 $res2 $res3 $res4 $res5 $res6 $out" EXIT
#INTRO
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=1 --borders=10 \
--text="$INTRO_TXT" --image=/usr/share/icons/hicolor/128x128/apps/mbcc.png \
--columns=4 --form \
--field="$USER_LBL:LBL" "" \
--field="$PKGS_INSTALLED:LBL" "" \
--field="$UPDCHECK:LBL" "" \
--field="$KERNEL_LBL:LBL" "" \
--field="<b>$USER</b>:LBL" "" \
--field="<b>$PKGS</b>:LBL" "" \
--field="<b>>>></b>:LBL" "" \
--field="<b>$KERN</b>:LBL" "" \
--field=" $USERS_MSM!system-config-users!:FBTN" "manjaro-settings-manager -m msm_users" \
--field=" Pamac!package-manager-icon!:FBTN" "pamac-manager" \
--field=" Pamac updater!software-update!:FBTN" "pamac-manager --updates" \
--field=" $KERNELS!distributor-logo-linux!:FBTN" "manjaro-settings-manager -m msm_kernel" \
--field=" :LBL" "" \
--field=" $PKGS_STAT (<small><tt>yay -Ps</tt></small>)!utilities-terminal!:FBTN" "foot -H -T 'Package stats' yay -Ps" \
--field=" $CLI_UPD (<small><tt>yay</tt></small>)!utilities-terminal!:FBTN" "foot -H -T 'Yay update' bash -c yay" \
--field=" :LBL" "" \
> $res1 &
# LABWC
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=2 \
--text="<b>Labwc</b> <small>ver: $LABWC_VER</small>\n<i>session:</i> ${XDG_SESSION_DESKTOP}\n\n" \
--form --columns=3 --align="center" \
--field="<b>Edit config files</b>:LBL" "" \
--field="rc.xml :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/rc.xml" \
--field="autostart :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/autostart" \
--field="environment :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/environment" \
--field="open config dir :FBTN" "pcmanfm $HOME/.config/${XDG_SESSION_DESKTOP}" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field="Reconfigure Labwc :FBTN" "labwc -r" \
--field="Labwc Tweaks:FBTN" "labwc-tweaks" \
--field="<b>Regenerate menu</b> :LBL" "" \
--field="Static :FBTN" "mabox-labwc-menu" \
--field="Dynamic :FBTN" "mabox-labwc-menu -p" \
--field="<b>Edit Labwc Menu</b>:LBL" "" \
--field="top :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/MENU_TOP.txt" \
--field="bottom :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/MENU_BOTTOM.txt" \
--field="IGNORE :FBTN" "geany $HOME/.config/${XDG_SESSION_DESKTOP}/MENU_IGNORE.txt" \
--field=" :LBL" "" \
> $res2 &
# WALLPAPER
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=3 \
--image="$HOME/.config/mabox/wpicon_labwc.png" --text="<big>Wallpaper</big>\n" \
--form --columns=3 \
--field="$WP_RANDOM :FBTN" "mb-wall random" \
--field="$WP_CHOOSE :FBTN" "pcmanwp" \
--field="WP_DEFAULT :FBTN" "mb-wall default" \
--field="$WP_DIRS :FBTN" "xdg-open $HOME/.config/mabox/wallp_dirs.conf" \
> $res3 &
# SYSTEM_SPRZET
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=4 --borders=0 --text="$SYSTEM_DESC" --columns=2 --align="center" --form --scroll \
--field="<b>$SETTINGS</b>:LBL" " " \
--field="$LOCALE_SETTINGS:FBTN" "manjaro-settings-manager -m msm_locale" \
--field="$LANGUAGE_PACKAGES:FBTN" "manjaro-settings-manager -m msm_language_packages" \
--field="$KERNEL:FBTN" "manjaro-settings-manager -m msm_kernel" \
--field="$USER_ACCOUNTS:FBTN" "manjaro-settings-manager -m msm_users" \
--field="$TIME_DATE:FBTN" "manjaro-settings-manager -m msm_timedate" \
--field="$KEYBOARD:FBTN" "lxinput" \
--field="$HARDWARE:FBTN" "manjaro-settings-manager -m msm_mhwd" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field="<b>Info</b>:LBL" "" \
--field=" inxi -CGAD!utilities-terminal!:FBTN" "foot -H -T 'inxi -CAGD system info' inxi -CGAD" \
--field=" $FETCH!utilities-terminal!:FBTN" "foot -L -H $FETCH" \
--field=" btop!utilities-terminal!:FBTN" "q-btop" \
--field=" :LBL" "" \
> $res4 &
# PANEL/DAR
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=5 \
--text="<big>Panel / Bar</big>\n <i>not implemented yet</i>" \
--form --columns=4 \
--field="Sfwbar :LBL" "" \
--field="Waybar :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
> $res5 &
# THEME
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=6 \
--text="<big>Themes</big>\n <i>not implemented yet</i>" \
--form --columns=3 \
--field=" :LBL" "" \
--field=" :LBL" "" \
--field=" :LBL" "" \
> $res6 &
# HELP
GDK_BACKEND=x11 yad --plug=$KEY --tabnum=7 \
--image=/usr/share/icons/hicolor/128x128/apps/distributor-logo-mabox-trans.png --text-justify=center --uri-handler=xdg-open --text="$HELP_TXT" \
--form --columns="4" \
--field="www:FBTN" "xdg-open https://maboxlinux.org" \
--field="forum:FBTN" "xdg-open https://forum.maboxlinux.org" \
--field="manual:FBTN" "xdg-open https://manual.maboxlinux.org/en/" \
--field="donate:FBTN" "xdg-open https://ko-fi.com/maboxlinux" \
> $res7 &
#main window
GDK_BACKEND=x11 yad --window-icon=mcc \
--notebook --tab-pos="left" --key=$KEY \
--tab="$START" \
--tab="Labwc" \
--tab="$WALLPAPER" \
--tab="$SYSTEM" \
--tab="<i>PANEL/BAR</i>" \
--tab="<i>$THEMES</i>" \
--tab="$HELP"\
--title="$TITLE - Labwc (beta)" --image=/usr/share/icons/hicolor/48x48/apps/mcc.png \
--width="720" --height="420" --image-on-top --text-justify=right --text="$MCC" --no-buttons > $out &
}
case "$XDG_SESSION_DESKTOP" in
openbox)maindialog;;
mabox-labwc|labwc)labdialog;;
*) exit 1;;
esac

106
bin/mcorners Executable file
View File

@@ -0,0 +1,106 @@
#!/usr/bin/env bash
#:Usage: mcorners [-tl cmd] [-t cmd] [-tr cmd] [-l cmd] [-r cmd] [-bl cmd] [-b cmd] [-br cmd] [-iof] [-v]
#:
#: cmd: run the command when mouse reach to the edge of screen:
#:
#: -tl cmd top-left
#: -t cmd top
#: -tr cmd top-right
#: -l cmd left
#: -r cmd right
#: -bl cmd bottom-left
#: -b cmd bottom
#: -br cmd bottom-right
#: -iof, --ignore-on-fullscreen disable command when active window
#: is fullscreen.
#: --stop force stop mcorners if it's running
#: -v verbose output
#: -h show the help
#:
# same as py version before, but faster
eval $(xdotool getdisplaygeometry --shell)
G=2;MR=8 W=$((WIDTH-G)); H=$((HEIGHT-G)); DB=/tmp/mcorners.lck;
#my
E=200;
X1=$((WIDTH/2-E/2));X2=$((X1+E));Y1=$((HEIGHT/2-E/2));Y2=$((Y1+E));
#my
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
options() {
while [[ "$1" ]]; do
case "$1" in
"-tl") tl="$2" ;;
"-t") t="$2" ;;
"-tr") tr="$2" ;;
"-l") l="$2" ;;
"-r") r="$2" ;;
"-bl") bl="$2" ;;
"-b") b="$2" ;;
"-br") br="$2" ;;
"-iof"|"--ignore-on-fullscreen") iof=1 ;;
"--stop") kill -9 $(cat $DB) && exit ;;
"-v") verbose=1 ;;
""|"-h"|"--help") usage ;;
esac
shift
done
}
delay() {
local IFS
[[ -n "${_de:-}" ]] || exec {_de}<> <(:)
read ${1:+-t "$1"} -u $_de || :
}
invoke() {
pkill -f jgmenu
proc=$(IFS=" "; set -- $1; echo $1)
id="$(pidof -x "$proc")"
if [[ -n "$verbose" ]]; then
[[ -z "$id" ]] && (eval "$1" &) || (kill -9 $id &)
else
[[ -z "$id" ]] && (eval "$1" 2&>/dev/null &) || (kill -9 $id 2&>/dev/null &)
fi
xdotool mousemove $2 $3
delay 1.2
}
quithandler() {
rm -f $DB
exit $?
}
trap quithandler SIGINT SIGTERM EXIT
[[ -f "$DB" && -z "$(cat $DB | xargs ps -p)" ]] && rm -rf $DB
[[ -z "$@" ]] && usage || options "$@"
if [[ ! -f "$DB" ]]; then
while :;do
[[ ! -f "$DB" ]] && printf "%s\n" $$ >$DB
eval $(xdotool getmouselocation --shell)
if [[ -n "$iof" && -n "$(xdotool getactivewindow 2>/dev/null | xargs xprop -id 2>/dev/null | grep E_FULLS)" ]]; then
delay 0.8
else
[[ -n "$tl" && "$X" -lt "$G" && "$Y" -lt "$G" ]] && invoke "$tl" $((X+MR)) $((Y+MR))
[[ -n "$t" && "$X" -gt "$X1" && "$X" -lt "$X2" && "$Y" -lt "$G" ]] && invoke "$t" $((X-0)) $((Y+MR))
[[ -n "$tr" && "$X" -gt "$W" && "$X" -le "$WIDTH" && "$Y" -lt "$G" ]] && invoke "$tr" $((X-MR)) $((Y+MR))
[[ -n "$l" && "$X" -lt "$G" && "$Y" -gt "$Y1" && "$Y" -lt "$Y2" ]] && invoke "$l" $((X+MR)) $((Y+0))
[[ -n "$r" && "$X" -gt "$W" && "$X" -le "$WIDTH" && "$Y" -gt "$Y1" && "$Y" -lt "$Y2" ]] && invoke "$r" $((X-MR)) $((Y+0))
[[ -n "$bl" && "$X" -lt "$G" && "$Y" -gt "$H" ]] && invoke "$bl" $((X+MR)) $((Y-MR))
[[ -n "$b" && "$X" -gt "$X1" && "$X" -lt "$X2" && "$Y" -gt "$H" ]] && invoke "$b" $((X+0)) $((Y-MR))
[[ -n "$br" && "$X" -gt "$W" && "$X" -le "$WIDTH" && "$Y" -gt "$H" ]] && invoke "$br" $((X-MR)) $((Y-MR))
fi
delay 0.2
done
exit 0
else
printf "Lock Exists: Mcorners is running at PID $(cat $DB). run \"mcorners --stop\" to close it.\n"
exit 1
fi

147
bin/mwelcome Executable file
View File

@@ -0,0 +1,147 @@
#!/bin/bash
export YAD_OPTIONS="--bool-fmt=t --separator='|'"
if [ -f "$HOME/.config/mabox/.mwelcome" ];then show_welcome=false;else show_welcome=true;fi
case $LANG in
pl*)
function homewww() {
exo-open --launch WebBrowser https://pl.maboxlinux.org
}
export -f homewww
function userguide() {
exo-open --launch WebBrowser https://pl.maboxlinux.org/przewodnik-uzytkownika/
}
export -f userguide
;;
es*)
function homewww() {
exo-open --launch WebBrowser https://maboxlinux.org
}
export -f homewww
function userguide() {
exo-open --launch WebBrowser https://manual.maboxlinux.org/es/
}
export -f userguide
;;
*)
function homewww() {
exo-open --launch WebBrowser https://maboxlinux.org
}
export -f homewww
function userguide() {
exo-open --launch WebBrowser https://manual.maboxlinux.org/en/
}
export -f userguide
;;
esac
FB="exo-open --launch WebBrowser www.facebook.com/maboxlinux/"
YT="exo-open --launch WebBrowser www.youtube.com/channel/UCuiznSWZXPCnkRKjNfWwF5Q"
case $LANG in
pl*)
TITLE="Witaj w Mabox!"
TXT1="Witaj <b>$USER</b> !\nDziękujemy za wybranie Mabox Linux. Mamy nadzieję, że używanie Mabox sprawi Ci tyle radości, co nam praca nad jego przygotowaniem.
Poniższe odnośniki pomogą Ci w rozpoczęciu używania nowego systemu.
\n<i>Życzymy miłych wrażeń, nie zapomnij podzielić się Maboxem ze znajomymi</i>\n"
START="<b>START</b>"
UPDATE="Uaktualnij system"
UPDATE_LBL="Aktualizacja systemu"
MCC="Mabox Control Center:FBTN"
ADD_KERNEL="Dodatkowe jądro!!Dobrą praktyką jest <b>instakacja dodatkowego kernela</b>. Kliknij, aby wybrać i zainstalować:FBTN"
RELNOTES="Popularne programy!!Instalacja najpopularniejszych programów:FBTN"
RESOURCES="<b>ZASOBY</b>"
QUICKSTART="Przewodnik użytkownika"
WWW="Strona WWW"
PROJECT="<b>PROJEKT</b>"
DEVELOPMENT="Rozwój:FBTN"
IRC="Kanał IRC:FBTN"
DONATE="Wesprzyj:FBTN"
LAUNCH_AT_START="Uruchamiaj przy starcie:CHK"
CLOSE="Zamknij"
;;
es*)
TITLE="Bienvenido a Mabox!"
KERN_LBL="kernel: "
TXT1="Bienvenido $USER ! \nGracias por elegir Mabox Linux. Esperamos que Ud. disfrute usando Mabox del mismo modo como nosotros disfrutamos en construirlo. Los vínculos de abajo le ayudarán para iniciar el uso de su nuevo sistema operativo.
\n<i>Disfrute esta experiencia, y no dude en enviarnos sus comentarios.</i>\n"
START="<b>INICIO</b>"
UPDATE="Actualizar el sistema"
UPDATE_LBL="System update"
MCC="Mabox Control Center:FBTN"
ADD_KERNEL="Agregar núcleo!!Es una buena idea tener más de un núcleo instalado. Sugerimos mantener un núcleo <b>LTS</b> y además <b>instalar otro más actualizado</b>.:FBTN"
RELNOTES="Instalar Aplicaciones!!Instale aplicaciones populares:FBTN"
RESOURCES="<b>RECURSOS</b>"
QUICKSTART="Guía de inicio rápido"
WWW="Sitio web"
PROJECT="<b>PROYECTO</b>"
DEVELOPMENT="Desarrollo:FBTN"
IRC="Canal IRC:FBTN"
DONATE="Donar:FBTN"
LAUNCH_AT_START="Lanzar al inicio:CHK"
CLOSE="Salir"
;;
*)
TITLE="Welcome to Mabox!"
KERN_LBL="kernel: "
TXT1="Welcome $USER ! \nThank you for choosing Mabox Linux. We hope that you will enjoy using Mabox as much as we enjoy building it. The links below will help you get started with your new operating system.
\n<i>Enjoy the experience, and don't hesitate to send us your feedback.</i>\n"
START="<b>START</b>"
UPDATE="Update system"
UPDATE_LBL="System update"
MCC="Mabox Control Center:FBTN"
RELNOTES="Install Popular Apps!!Install popular applications:FBTN"
RESOURCES="<b>RESOURCES</b>"
QUICKSTART="Quick Start Guide"
WWW="Website"
PROJECT="<b>PROJECT</b>"
DEVELOPMENT="Development:FBTN"
IRC="IRC channel:FBTN"
DONATE="Donate:FBTN"
LAUNCH_AT_START="Launch at start:CHK"
CLOSE="Exit"
;;
esac
OSNAME=$(lsb_release -d | awk '{print $2}')
OSVERSION=$(lsb_release -r | awk '{print $2}')
OSCODE=$(lsb_release -c | awk '{print $2}')
FONT="foreground='dark green' font='14'"
values=($(yad --window-icon=distributor-logo-mabox --center --buttons-layout="edge" --borders=20 --width=520 --height=380 \
--image=/usr/share/icons/mabox_trans_64.png --image-on-top \
--text="<span $FONT>$OSNAME $OSVERSION $OSCODE</span>\n\n$TXT1" \
--title="$TITLE" \
--columns=3 --align="center" --form \
--field="$START:LBL" ""\
--field="$UPDATE:FBTN" "pamac-manager --updates" \
--field="$MCC" "mcc" \
--field="$RELNOTES" "manjaro-application-utility"\
--field=" :LBL" ""\
--field="$RESOURCES:LBL" ""\
--field="$QUICKSTART:FBTN" "bash -c userguide"\
--field="$WWW:FBTN" "bash -c homewww"\
--field="Forum:FBTN" "exo-open --launch WebBrowser forum.maboxlinux.org"\
--field=" :LBL" ""\
--field="$PROJECT:LBL" ""\
--field="$DEVELOPMENT" "exo-open --launch WebBrowser https://git.maboxlinux.org/Mabox"\
--field="$DONATE" "exo-open --launch WebBrowser https://ko-fi.com/maboxlinux"\
--field="$LAUNCH_AT_START" "$show_welcome" \
--button=" FB":"$FB" --button="輸 YT":"$YT" --button=$CLOSE:0))
#if [ $? -eq 0 ]; then
while IFS='|' read -ra ADDR; do
VAL=${ADDR[13]}
done <<< "$values"
case $VAL in
true)
rm $HOME/.config/mabox/.mwelcome
;;
false)
touch $HOME/.config/mabox/.mwelcome
;;
esac
exit

86
bin/obxml Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/bash
# helper script for editing Openbox rc.xml config file
nspace="http://openbox.org/3.4/rc"
rcxml="$HOME/.config/openbox/rc.xml"
reconf=0
sel(){
xml sel -N a="$nspace" -t -v ${1} "$rcxml"
}
set(){
xml ed -L -N a="$nspace" -u ${1} -v ${2} "$rcxml"
reconf=1
}
setonly(){
xml ed -L -N a="$nspace" -u ${1} -v ${2} "$rcxml"
}
switch_desk(){
case "$1" in
on)
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Click"][@button="Up"]/a:action/a:to' previous
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Click"][@button="Down"]/a:action/a:to' next
;;
off)
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Click"][@button="Up"]/a:action/a:to' none
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Click"][@button="Down"]/a:action/a:to' none
;;
esac
}
show_desk(){
case "$1" in
on)
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Press"][@button="Left"]/a:action/@name' ToggleShowDesktop
;;
off)
set '/a:openbox_config/a:mouse/a:context[@name="Root"]/a:mousebind[@action="Press"][@button="Left"]/a:action/@name' none
;;
esac
}
focus_follow_mouse(){
case "$1" in
on)
set '/a:openbox_config/a:focus/a:followMouse' yes
set '/a:openbox_config/a:focus/a:raiseOnFocus' yes
;;
off)
set '/a:openbox_config/a:focus/a:followMouse' no
set '/a:openbox_config/a:focus/a:raiseOnFocus' no
;;
esac
}
desktops() {
set '/a:openbox_config/a:desktops/a:number' ${1}
wmctrl -n ${1}
}
margin() {
case "$1" in
top|bottom|left|right)
setonly "/a:openbox_config/a:margins/a:${1}" ${2}
;;
all)
setonly "/a:openbox_config/a:margins/a:top" ${2}
setonly "/a:openbox_config/a:margins/a:bottom" ${2}
setonly "/a:openbox_config/a:margins/a:left" ${2}
setonly "/a:openbox_config/a:margins/a:right" ${2}
;;
esac
reconf=1
}
case "$1" in
sel)sel "$2";;
set)set "$2" "$3";;
switch_desk)switch_desk "$2";;
show_desk)show_desk "$2";;
focus_follow_mouse)focus_follow_mouse "$2";;
desktops)desktops "$2";;
margin)margin "$2" "$3";;
esac
[[ "$reconf" = "1" ]] && openbox --reconfigure

373
bin/phwmon.py Executable file
View File

@@ -0,0 +1,373 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GPLv2
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
import argparse
import cairo
import subprocess
import psutil
def normalize_color_hex(s):
if s[0] == "#":
s = s[1:]
if len(s) == 3:
s = s[0] + s[0] + s[1] + s[1] + s[2] + s[2]
if len(s) == 4:
s = s[0] + s[0] + s[1] + s[1] + s[2] + s[2] + s[3] + s[3]
if len(s) == 6:
s += "ff"
assert(len(s) == 8)
return s
def color_hex_to_float(s):
s = normalize_color_hex(s)
return [int(s[0:2], 16)/255.0, int(s[2:4], 16)/255.0, int(s[4:6], 16)/255.0, int(s[6:8], 16)/255.0]
def color_hex_to_int(s):
s = normalize_color_hex(s)
return int(s, 16)
def bytes2human(n):
# http://code.activestate.com/recipes/578019
# >>> bytes2human(10000)
# '9.8 K'
# >>> bytes2human(100001221)
# '95.4 M'
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i + 1) * 10
for s in reversed(symbols):
if n >= prefix[s]:
value = float(n) / prefix[s]
return '%.1f %sB' % (value, s)
return "%s B" % n
# Parameters
parser = argparse.ArgumentParser()
parser.add_argument("--cpu", help="Show a CPU activity graph", dest="cpu", action="store_true")
parser.add_argument("--cpu_alert_max", help="Blink when CPU load goes above defined percentage. Default: 100", dest="cpu_alert_max", default=100, type=int)
parser.add_argument("--core", help="Show a CPU activity graph for each logical CPU core", dest="core", action="store_true")
parser.add_argument("--mem", help="Show a memory usage graph", dest="mem", action="store_true")
parser.add_argument("--mem_percent", help="Tooltip: Show used memory in percentage", dest="mem_percent", action="store_true")
parser.add_argument("--mem_alert_max", help="Blink when memory usage goes above defined percentage. Default: 100", dest="mem_alert_max", default=100, type=int)
parser.add_argument("--swap", help="Show a swap usage graph", dest="swap", action="store_true")
parser.add_argument("--swap_percent", help="Tooltip: Show used swap in percentage", dest="swap_percent", action="store_true")
parser.add_argument("--swap_alert_max", help="Blink when swap usage goes above defined percentage. Default: 100", dest="swap_alert_max", default=100, type=int)
parser.add_argument("--net", help="Show a network usage graph", dest="net", action="store_true")
parser.add_argument("--net_scale", help="Maximum value for the network usage graph, in Mbps. Default: 40.", default=40, type=int)
parser.add_argument("--net_alert_max", help="Blink when network usage goes above defined percentage. Default: 100 ", dest="net_alert_max", default=100, type=int)
parser.add_argument("--io", help="Show a disk I/O graph", dest="io", action="store_true")
parser.add_argument("--io_scale", help="Maximum value for the disk I/O graph, in MB/s. Default: 100.", default=100, type=int)
parser.add_argument("--io_alert_max", help="Blink when disk I/O goes above defined percentage. Default: 100", dest="io_alert_max", default=100, type=int)
parser.add_argument("--size", help="Icon size in pixels. Default: 22.", default=22, type=int)
parser.add_argument("--invert", help="Try to invert order of icons ( might not work as it depends highly on the system tray used )", dest="invert", action="store_true")
parser.add_argument("--interval", help="Refresh interval in miliseconds. Default: 1000 (1sec).", default=1000, type=int)
parser.add_argument("--alert_interval", help="Alert blink interval in miliseconds. Default: 1000 (1sec).", default=1000, type=int)
parser.add_argument("--bg", help="Background color (RGBA hex). Default: #DDDDDD60.", default="#DDDDDD60")
parser.add_argument("--fg_cpu", help="CPU graph color (RGBA hex). Default: #70b433.", default="#70b433")
parser.add_argument("--fg_mem", help="Memory graph color (RGBA hex). Default: #efc541.", default="#efc541")
parser.add_argument("--fg_swap", help="Swap graph color (RGBA hex). Default: #ff81ca.", default="#ff81ca")
parser.add_argument("--fg_net", help="Network graph color (RGBA hex). Default: #368aeb.", default="#368aeb")
parser.add_argument("--fg_io", help="Disk I/O graph color (RGBA hex). Default: #ff5e56.", default="#ff5e56")
parser.add_argument("--fg_alert", help="Alert color (RGBA hex). Default: #ff0000cc.", default="#ff0000cc")
parser.add_argument("--task_manager", help="Task manager to execute on left click. Default: None.")
parser.set_defaults(cpu=False)
parser.set_defaults(core=False)
parser.set_defaults(mem=False)
parser.set_defaults(swap=False)
parser.set_defaults(net=False)
parser.set_defaults(io=False)
args = parser.parse_args()
w = h = args.size
invert = args.invert
interval = args.interval
alertInterval = args.alert_interval
bgCol = color_hex_to_int(args.bg)
fgCpu = color_hex_to_float(args.fg_cpu)
fgRam = color_hex_to_float(args.fg_mem)
fgSwap = color_hex_to_float(args.fg_swap)
fgNet = color_hex_to_float(args.fg_net)
fgDiskIo = color_hex_to_float(args.fg_io)
fgAlert = color_hex_to_int(args.fg_alert)
cpuEnabled = args.cpu or args.core
cpuAlertMax = args.cpu_alert_max
mergeCpus = not args.core
ramEnabled = args.mem
memPercent = args.mem_percent
memAlertMax = args.mem_alert_max
swapEnabled = args.swap
swapPercent = args.swap_percent
swapAlertMax = args.swap_alert_max
netEnabled = args.net
netScale = args.net_scale
netAlertMax = args.net_alert_max
diskIoEnabled = args.io
diskIoScale = args.io_scale
diskIoAlertMax = args.io_alert_max
taskMgr = args.task_manager
if not cpuEnabled and not ramEnabled and not swapEnabled and not netEnabled and not diskIoEnabled:
cpuEnabled = mergeCpus = ramEnabled = swapEnabled = netEnabled = diskIoEnabled = True
class HardwareMonitor:
alertState = False
def __init__(self):
if invert:
self.initDiskIo()
self.initNet()
self.initSwap()
self.initRam()
self.initCpus()
self.drawDiskIo()
self.drawNet()
self.drawSwap()
self.drawRam()
self.drawCpus()
else:
self.initCpus()
self.initRam()
self.initSwap()
self.initNet()
self.initDiskIo()
self.drawCpus()
self.drawRam()
self.drawSwap()
self.drawNet()
self.drawDiskIo()
GLib.timeout_add(interval, self.update)
GLib.timeout_add(alertInterval, self.alertFlip)
def alertFlip(self):
self.alertState = not self.alertState
return True
def rightClickEvent(self, icon, button, time):
menu = Gtk.Menu()
quit = Gtk.MenuItem("Quit")
quit.connect("activate", Gtk.main_quit)
menu.append(quit)
menu.show_all()
menu.popup(None, None, Gtk.status_icon_position_menu, button, time, icon)
def leftClickEvent (self, icon):
if not taskMgr:
return
subprocess.Popen(taskMgr)
def initCpus(self):
if not cpuEnabled:
return
if mergeCpus:
self.cpus = [[0 for x in range(w)]]
psutil.cpu_percent(percpu=mergeCpus)
else:
self.cpus = [[0 for x in range(w)] for c in range(len(psutil.cpu_percent(percpu=not mergeCpus)))]
self.cpuIcons = [Gtk.StatusIcon() for c in range(len(self.cpus))]
for c in range(len(self.cpus)):
self.cpuIcons[c].set_title("hwmon 1 cpu{0}".format("" if mergeCpus else (" " + str(c+1))))
self.cpuIcons[c].connect("popup-menu", self.rightClickEvent)
self.cpuIcons[c].connect("activate", self.leftClickEvent)
self.cpuIcons[c].set_visible(True)
def updateCpus(self):
if not cpuEnabled:
return
vals = psutil.cpu_percent(percpu=not mergeCpus)
if mergeCpus:
vals = [vals]
for c in range(len(vals)):
self.cpus[c].append(vals[c])
self.cpus[c].pop(0)
self.cpuIcons[c].set_tooltip_text("CPU{0}: {1}%".format("" if mergeCpus else (" " + str(c+1)), vals[c]))
def drawCpus(self):
if not cpuEnabled:
return
for c in range(len(self.cpus)):
self.drawGraph(self.cpus[c], self.cpuIcons[c], bgCol, fgCpu)
self.drawAlert(self.cpus[c], self.cpuIcons[c], fgAlert, cpuAlertMax)
def initRam(self):
if not ramEnabled:
return
self.ram = [0 for x in range(w)]
self.ramIcon = Gtk.StatusIcon()
self.ramIcon.set_title("hwmon 2 memory")
self.ramIcon.connect("popup-menu", self.rightClickEvent)
self.ramIcon.connect("activate", self.leftClickEvent)
self.ramIcon.set_visible(True)
def updateRam(self):
if not ramEnabled:
return
mem = psutil.virtual_memory()
total = mem[0]
used = mem[3]
used_percent = mem[2]
self.ram.append(used_percent)
self.ram.pop(0)
if memPercent:
self.ramIcon.set_tooltip_text("Memory: %d%% used of %s" % (used_percent, bytes2human(total)))
else:
self.ramIcon.set_tooltip_text("Memory: %s used of %s" % (bytes2human(used), bytes2human(total)))
def drawRam(self):
if not ramEnabled:
return
self.drawGraph(self.ram, self.ramIcon, bgCol, fgRam)
self.drawAlert(self.ram, self.ramIcon, fgAlert, memAlertMax)
def initSwap(self):
if not swapEnabled:
return
self.swap = [0 for x in range(w)]
self.swapIcon = Gtk.StatusIcon()
self.swapIcon.set_title("hwmon 3 swap")
self.swapIcon.connect("popup-menu", self.rightClickEvent)
self.swapIcon.connect("activate", self.leftClickEvent)
def updateSwap(self):
if not swapEnabled:
return
swap = psutil.swap_memory()
total = swap[0]
used = swap[1]
used_percent = swap[3]
if bool(self.swapIcon.get_visible()) != bool(total):
self.swapIcon.set_visible(total)
self.swap.append(used_percent)
self.swap.pop(0)
if swapPercent:
self.swapIcon.set_tooltip_text("Swap: %d%% used of %s" % (used_percent, bytes2human(total)))
else:
self.swapIcon.set_tooltip_text("Swap: %s used of %s" % (bytes2human(used), bytes2human(total)))
def drawSwap(self):
if not swapEnabled:
return
self.drawGraph(self.swap, self.swapIcon, bgCol, fgSwap)
self.drawAlert(self.swap, self.swapIcon, fgAlert, swapAlertMax)
def initNet(self):
if not netEnabled:
return
self.net = [0 for x in range(w)]
v = psutil.net_io_counters(pernic=False)
self.netBytes = v[0] + v[1]
self.netIcon = Gtk.StatusIcon()
self.netIcon.set_title("hwmon 4 network")
self.netIcon.connect("popup-menu", self.rightClickEvent)
self.netIcon.connect("activate", self.leftClickEvent)
self.netIcon.set_visible(True)
def updateNet(self):
if not netEnabled:
return
v = psutil.net_io_counters(pernic=False)
v = v[0] + v[1]
delta = v - self.netBytes
self.netBytes = v
self.net.append(delta * 8 / 1.0e6)
self.net.pop(0)
self.netIcon.set_tooltip_text("Network: %.1f Mb/s" % (delta * 8 / 1.0e6))
def drawNet(self):
if not netEnabled:
return
self.drawGraph(self.net, self.netIcon, bgCol, fgNet, netScale)
self.drawAlert(self.net, self.netIcon, fgAlert, netAlertMax, netScale)
def initDiskIo(self):
if not diskIoEnabled:
return
self.diskIo = [0 for x in range(w)]
v = psutil.disk_io_counters(perdisk=False)
self.diskIoBytes = v[2] + v[3]
self.diskIoIcon = Gtk.StatusIcon()
self.diskIoIcon.set_title("hwmon 5 disk i/o")
self.diskIoIcon.connect("popup-menu", self.rightClickEvent)
self.diskIoIcon.connect("activate", self.leftClickEvent)
self.diskIoIcon.set_visible(True)
def updateDiskIo(self):
if not diskIoEnabled:
return
v = psutil.disk_io_counters(perdisk=False)
v = v[2] + v[3]
delta = v - self.diskIoBytes
self.diskIoBytes = v
self.diskIo.append(delta / 1.0e6 / 10)
self.diskIo.pop(0)
partitions = psutil.disk_partitions(all=False)
strPartitions = ""
for part in psutil.disk_partitions(all=False):
if 'cdrom' in part.opts or part.fstype == '':
continue
usage = psutil.disk_usage(part.mountpoint)
strPartitions += "\n%s %d%% of %s (%s)" % (part.mountpoint, int(usage.percent), bytes2human(usage.total), part.fstype)
self.diskIoIcon.set_tooltip_text("Disk I/O: %.1f MB/s\n%s" % (delta / 1.0e6 / 10, strPartitions))
def drawDiskIo(self):
if not diskIoEnabled:
return
self.drawGraph(self.diskIo, self.diskIoIcon, bgCol, fgDiskIo, diskIoScale)
self.drawAlert(self.diskIo, self.diskIoIcon, fgAlert, diskIoAlertMax, diskIoScale)
def drawGraph(self, graph, icon, bgCol, fgCol, max=100):
bg = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
bg.fill(bgCol)
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h)
cr = cairo.Context(surface)
cr.set_source_rgba(fgCol[2], fgCol[1], fgCol[0], fgCol[3])
for x in range(w):
y = int(round(graph[x]/max * h))
if y:
cr.move_to(x, h)
cr.line_to(x, h - y)
cr.stroke()
pixbuf = GdkPixbuf.Pixbuf.new_from_data(surface.get_data(), GdkPixbuf.Colorspace.RGB, True, 8, w, h, w * 4, None, None)
pixbuf.composite(bg, 0, 0, w, h, 0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 255)
icon.set_from_pixbuf(bg)
def drawAlert(self, graph, icon, fgCol, threshold, max=100):
if graph[-1] < threshold or not self.alertState:
return
bg = icon.get_pixbuf()
fg = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
fg.fill(fgCol)
fg.composite(bg, 0, 0, w, h, 0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 255)
icon.set_from_pixbuf(bg)
def update(self):
self.updateCpus()
self.updateRam()
self.updateSwap()
self.updateNet()
self.updateDiskIo()
self.drawCpus()
self.drawRam()
self.drawSwap()
self.drawNet()
self.drawDiskIo()
return True
if __name__ == '__main__':
HardwareMonitor()
Gtk.main()

70
bin/quake-radio Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# Show/hide terminal with pyradio.
GEOMETRY_FILE="$HOME/.config/.quake-radio"
TERM_CONFIG="$HOME/.config/terminator/transparent"
NAME="Quake Radio"
__run() {
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
if [ -z "${ID}" ]; then
if [ ! -f $TERM_CONFIG ]; then
cat <<EOF > ${TERM_CONFIG}
[global_config]
dbus = False
[keybindings]
[profiles]
[[default]]
allow_bold = False
background_darkness = 0.0
background_type = transparent
cursor_blink = False
cursor_color = "#aaaaaa"
font = JetBrains Mono NL 9
show_titlebar = False
scrollbar_position = hidden
scroll_on_keystroke = False
use_custom_command = False
use_system_font = False
[layouts]
[plugins]
EOF
fi
if [ -f "$GEOMETRY_FILE" ]; then
POS=$(head -n 1 $GEOMETRY_FILE)
terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "$POS" -e 'pyradio -lt'
else
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
ONESIXTH=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/6]
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
LEFT=$[${ONESIXTH}*5-80]
WIDTH=$[${ONESIXTH}+60]
terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -e 'pyradio -lt'
fi
else
ID_DEC=$((${ID}))
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
xdotool windowminimize ${ID_DEC}
else
xdotool windowactivate ${ID_DEC}
fi
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
fi
}
__save() {
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
}
__reset() {
rm -f $GEOMETRY_FILE
}
case "$1" in
reset) __reset;;
*) __run;;
esac

45
bin/quake-term Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# Author: Daniel Napora <napcok@gmail.com> 2018-2024, https://maboxlinux.org
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. C-~ or F12.
# Depenging on actual state it will start, show or hide terminal window.
GEOMETRY_FILE="$HOME/.config/.quake-term"
NAME="Quake Term"
__run() {
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
if [ -z "${ID}" ]; then
if [ -f "$GEOMETRY_FILE" ]; then
POS=$(head -n 1 $GEOMETRY_FILE)
terminator -T "${NAME}" -b --geometry "$POS" -i utilities-terminal
else
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
LEFT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/8]
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
WIDTH=$[${LEFT}*6]
terminator -T "${NAME}" -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -i utilities-terminal
fi
else
ID_DEC=$((${ID}))
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
xdotool windowminimize ${ID_DEC}
else
xdotool windowactivate ${ID_DEC}
fi
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
fi
}
__reset() {
rm "$GEOMETRY_FILE"
}
case "$1" in
reset) __reset;;
*) __run;;
esac
exit 0

12
bin/reload-gtk Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
mkdir -p $HOME/.config/xsettingsd
gtk_theme="$(grep "^[^#]*gtk-theme-name" "${HOME}/.config/gtk-3.0/settings.ini")"
gtk_theme="${gtk_theme/gtk-theme-name*=}"
echo "Net/ThemeName \"$gtk_theme\"" > "$HOME/.config/xsettingsd/xsettingsd.conf"
gtk_theme_icons="$(grep "^[^#]*gtk-icon-theme-name" "${HOME}/.config/gtk-3.0/settings.ini")"
gtk_theme_icons="${gtk_theme_icons/gtk-icon-theme-name*=}"
echo "Net/IconThemeName \"$gtk_theme_icons\"" >> "$HOME/.config/xsettingsd/xsettingsd.conf"
bl-reload-gtk23

35
bin/run_wallpaperslideshow Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
case $LANG in
pl*)
TITLE="Tapetowy pokaz slajdów"
TEXT="Uruchomiony został tapetowy pokaz slajdów.\nAby zakończyć kliknij ikonę w zasobniku systemowym."
CLICK="Kliknij aby zatrzymać tapetowy pokaz slajdów"
;;
*)
TITLE="Wallpaper Slideshow"
TEXT="Wallpaper Slideshow started!\nTo quit just click icon in systemtray."
CLICK="Click to stop Wallpaper slideshow"
;;
esac
COLORIZER_CONF="$HOME/.config/colorizer/colorizer.conf"
source ${COLORIZER_CONF}
if [[ "$wall2themes" == "yes" ]];then
mb-setvar wall2themes=no "$COLORIZER_CONF"
fi
mbwallpaper -s &
mbwallpaper_pid=$!
notify-send.sh -i emblem-photos "$TITLE" "$TEXT"
yad --notification --image emblem-photos --text "$CLICK"
kill -9 $mbwallpaper_pid
if [[ "$wall2themes" == "yes" ]];then
mb-setvar wall2themes=yes "$COLORIZER_CONF"
fi
#wait $mbwallpaper_pid

7
bin/show_desktop Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
if wmctrl -m | grep "mode: ON"; then
exec wmctrl -k off
else
exec wmctrl -k on
fi

184
bin/snapwin Executable file
View File

@@ -0,0 +1,184 @@
#!/bin/bash
#: snapwin - click on the appropriate area of the window to snap it in a given direction.
#: Works with active and inactive windows.
#: Same actions are available for kebindings: topleft, top, topright, left, center, right,
#: bottomleft, bottom and bottomright.
# Copyright (C) Daniel Napora <napcok@gmail.com> 2021-24
# https://maboxlinux.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
_config() {
CONFIG_DIR="$HOME/.config/deskgrid"
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Grid columns (12 16 24)
columns=12
# Grid rows (6 12 16)
rows=12
#Notifications true or false
notifications=true
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for clicksnap action
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
## OUTER GAP
if [[ "$show_outer_gap" == "true" ]]; then OUT_GAP=$((GAP/2)) ; else OUT_GAP="0" ; fi
OFFSET=$(wmctrl -d |grep "*" | awk -F' ' '{print $8}')
REALSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $9}')
AVAIL_X="${REALSIZE%x*}"
AVAIL_Y="${REALSIZE#*x}"
OFF_X="${OFFSET%,*}"
OFF_Y="${OFFSET#*,}"
}
_movewin() {
WIDTH_FULL=$((AVAIL_X-OUT_GAP*2-BORDERCOMP_X))
WIDTH_HALF=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X))
WIDTH_SMALL=$((AVAIL_X/3-OUT_GAP-GAP/2-BORDERCOMP_X))
WIDTH_WIDE=$((WIDTH_SMALL*2+GAP+BORDERCOMP_X))
HEIGHT_FULL=$((AVAIL_Y-OUT_GAP*2-BORDERCOMP_Y))
HEIGHT_HALF=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2))
case $POS_CODE in
00|"topleft") # top-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP));
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE
;;
10|top) # top
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
;;
20|topright) # top-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
;;
01|left) # left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE;;
11|center) # center
HEIGHT_SMALL=$((AVAIL_Y/3-OUT_GAP-GAP/2-BORDERCOMP_Y))
W=$WIDTH_FULL H=$HEIGHT_FULL XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$WIDTH_FULL+BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
[[ "$X" -eq "$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((WIDTH_SMALL+BORDERCOMP_X))" ]] && W=$((AVAIL_X/10*8)) H=$((AVAIL_Y/10*8)) XPOS=$((AVAIL_X/10)) YPOS=$((AVAIL_Y/10))
;;
21|right) # right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
;;
02|bottomleft) # bottom-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" ]] && W=$WIDTH_WIDE
;;
12|bottom) # bottom
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
;;
22|bottomright) # bottom-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X));;&
esac
xdotool windowsize $WINDOW $W $H
xdotool windowmove $WINDOW $XPOS $YPOS
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
}
_getwin() { #get active window (only when invoked by keyboard)
_config
WIN=$(xdotool getactivewindow)
HEX_ID=$(printf '0x%x\n' $WIN)
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
WINDOW=$(xwininfo -id $(xdotool getactivewindow) -int -tree | awk '/^ *Parent/ {print $4}')
winFRAME=$(xprop -id $WIN _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$winFRAME"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
eval $(xdotool getwindowgeometry --shell $WINDOW)
_movewin
}
clicksnap() {
_config
### Clicksnap mouse action start
eval $(xdotool getmouselocation --shell)
Mouse_x="$X"
Mouse_y="$Y"
HEX_ID=$(printf '0x%x\n' $WINDOW)
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
if xwininfo -id $CHILD_ID -wm |grep Dock ; then exit 0 ;fi # Ignore Dock eg. tint2
eval $(xdotool getwindowgeometry --shell $WINDOW)
Win_x="$X"
Win_y="$Y"
Win_width="$WIDTH"
Win_height="$HEIGHT"
if [[ $Mouse_x -gt $Win_x && $Mouse_x -lt $((Win_x+WIDTH)) && $Mouse_y -gt $Win_y && $Mouse_y -lt $((Win_y+HEIGHT)) ]];then
pos_x="$(((Mouse_x-Win_x)/(Win_width/3)))"
pos_y="$(((Mouse_y-Win_y)/(Win_height/3)))"
POS_CODE="$pos_x$pos_y"
else
pos_x="$((Mouse_x*3/AVAIL_X))"
pos_y="$((Mouse_y*3/AVAIL_Y))"
POS_CODE="$pos_x$pos_y"
fi
CHILD=$(printf %i $CHILD_ID)
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$(xprop -id $CHILD _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
_movewin
}
moveto() {
POS_CODE="$1"
_getwin
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
"") clicksnap ;;
topleft|top|topright|left|center|right|bottomleft|bottom|bottomright) moveto "$1" ;;
-h|--help) usage ;;
esac

259
bin/superclick Executable file
View File

@@ -0,0 +1,259 @@
#!/bin/bash
#: superclick - click on the appropriate area of the window to snap it in a given direction.
#: Works with active and inactive windows.
#: Same actions are available for keybindings: topleft, top, topright, left, center, right,
#: bottomleft, bottom and bottomright.
#: Requirements: X11, xwininfo, xprop, xdotool, wmctrl
# Copyright (C) Daniel Napora <danieln@maboxlinux.org> 2021-25
# https://maboxlinux.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# TODO: XFCE: Test it on XFCE with Workspace Margins
# TODO: XFCE: check if possible to bind actions to frame (for mouse clicks)
CONFIG_FILE="$HOME/.config/superclick.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for mouse action
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
_config() {
## OUTER GAP
[[ "$show_outer_gap" == "true" ]] && OUT_GAP=$((GAP/2)) || OUT_GAP="0"
read OFFSET REALSIZE <<< $(wmctrl -d |grep "*" | awk -F' ' '{print $8, $9}')
OFF_X="${OFFSET%,*}"
OFF_Y="${OFFSET#*,}"
AVAIL_X="${REALSIZE%x*}"
AVAIL_Y="${REALSIZE#*x}"
}
_movewin() {
while read -r line; do
info=$(echo $line | awk '{print $3}')
if [[ $info == primary ]]; then
info=$(echo $line | awk '{print $4}')
fi
read M_WIDTH M_HEIGHT M_X_OFF M_Y_OFF <<< $(echo $info | awk -F[x+] '{print $1, $2, $3, $4}')
if (( P_X >= M_X_OFF && P_X <= M_WIDTH + M_X_OFF && P_Y >= M_Y_OFF && P_Y <= M_HEIGHT + M_Y_OFF )); then
break
fi
done < <(xrandr | grep " connected")
### This may be calculated probably from `wmctrl -d` (?)
if [[ "$XDG_SESSION_DESKTOP" == "openbox" ]];then
# Openbox calculate with margin right and bottom
m_right=$(obxml sel /a:openbox_config/a:margins/a:right)
m_bottom=$(obxml sel /a:openbox_config/a:margins/a:bottom)
AVAIL_X=$((M_WIDTH-OFF_X-m_right))
AVAIL_Y=$((M_HEIGHT-OFF_Y-m_bottom))
else
AVAIL_X=$((M_WIDTH-OFF_X))
AVAIL_Y=$((M_HEIGHT-OFF_Y))
fi
WIDTH_FULL=$((AVAIL_X-OUT_GAP*2-BORDERCOMP_X))
WIDTH_HALF=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X))
WIDTH_SMALL=$((AVAIL_X/3-OUT_GAP-GAP/2-BORDERCOMP_X))
WIDTH_WIDE=$((WIDTH_SMALL*2+GAP+BORDERCOMP_X))
HEIGHT_FULL=$((AVAIL_Y-OUT_GAP*2-BORDERCOMP_Y))
HEIGHT_HALF=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2))
case $POS_CODE in
00|"topleft") # top-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+OFF_Y+OUT_GAP));
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE
;;
10|top) # top
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+0+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((M_X_OFF+OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
;;
20|topright) # top-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((M_Y_OFF+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((M_X_OFF+OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((M_X_OFF+AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((M_X_OFF+AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
;;
01|left) # left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((M_X_OFF+0+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE;;
11|center) # center
HEIGHT_SMALL=$((AVAIL_Y/3-OUT_GAP-GAP/2-BORDERCOMP_Y))
W=$WIDTH_FULL H=$HEIGHT_FULL XPOS=$((M_X_OFF+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$WIDTH_FULL+BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((M_X_OFF+OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
[[ "$X" -eq "$((M_X_OFF+OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((WIDTH_SMALL+BORDERCOMP_X))" ]] && W=$((AVAIL_X/10*8)) H=$((AVAIL_Y/10*8)) XPOS=$((M_X_OFF+AVAIL_X/10)) YPOS=$((M_Y_OFF+AVAIL_Y/10))
;;
21|right) # right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((M_X_OFF+AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((M_Y_OFF+0+OFF_Y+OUT_GAP))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((M_X_OFF+OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((M_X_OFF+AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((M_X_OFF+AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
;;
02|bottomleft) # bottom-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+0+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W=$WIDTH_SMALL
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" ]] && W=$WIDTH_WIDE
;;
12|bottom) # bottom
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+0+OFF_X+OUT_GAP)) YPOS=$((M_Y_OFF+AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((M_X_OFF+OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
;;
22|bottomright) # bottom-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((M_X_OFF+AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((M_Y_OFF+AVAIL_Y/2+OFF_Y+GAP/2))
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W="$WIDTH_SMALL" XPOS=$((M_X_OFF+OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
[[ "$X" -eq "$((M_X_OFF+AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" ]] && W=$WIDTH_WIDE XPOS=$((M_X_OFF+AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X));;&
esac
xdotool windowsize $WINDOW $W $H
xdotool windowmove $WINDOW $XPOS $YPOS
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
#_debug
}
_getwin() { #get active window (only when invoked by keyboard)
_config
WIN=$(xdotool getactivewindow)
HEX_ID=$(printf '0x%x\n' $WIN)
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
WINDOW=$(xwininfo -id $(xdotool getactivewindow) -int -tree | awk '/^ *Parent/ {print $4}')
winFRAME=$(xprop -id $WIN _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$winFRAME"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
eval $(xdotool getwindowgeometry --shell $WINDOW)
#CLICK_POINT - here it is active window position
P_X="$X"
P_Y="$Y"
_movewin
}
clicksnap() {
_config
### Clicksnap mouse action start
eval $(xdotool getmouselocation --shell)
Mouse_x="$X"
Mouse_y="$Y"
HEX_ID=$(printf '0x%x\n' $WINDOW)
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
if xwininfo -id $CHILD_ID -wm |grep 'Dock\|Desktop' ; then exit 0 ;fi # Ignore Dock eg. tint2
eval $(xdotool getwindowgeometry --shell $WINDOW)
Win_x="$X"
Win_y="$Y"
Win_width="$WIDTH"
Win_height="$HEIGHT"
if [[ $Mouse_x -gt $Win_x && $Mouse_x -lt $((Win_x+WIDTH)) && $Mouse_y -gt $Win_y && $Mouse_y -lt $((Win_y+HEIGHT)) ]];then
pos_x="$(((Mouse_x-Win_x)/(Win_width/3)))"
pos_y="$(((Mouse_y-Win_y)/(Win_height/3)))"
POS_CODE="$pos_x$pos_y"
else
pos_x="$((Mouse_x*3/AVAIL_X))"
pos_y="$((Mouse_y*3/AVAIL_Y))"
POS_CODE="$pos_x$pos_y"
fi
CHILD=$(printf %i $CHILD_ID)
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$(xprop -id $CHILD _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
#CLICK_POINT
P_X="$Mouse_x"
P_Y="$Mouse_y"
_movewin
}
moveto() {
POS_CODE="$1"
_getwin
}
_debug() {
cat <<EOF > "$HOME/.config/superclick_debug"
Clickpoint ${P_X} ${P_Y}
Available area: $AVAIL_X $AVAIL_Y Monitor W,H and OFFSET $M_WIDTH x $M_HEIGHT $M_X_OFF $M_Y_OFF
EOF
}
trainer(){
case "$LANG" in
pl*)
TITLE="Trener SuperClick"
MOUSE="przytrzymaj klawisz <kbd>super</kbd> i kliknij w wybrany obszar okna<br /><br /><em>...kolejne kliknięcia zmieniają rozmiar</em><br /><br /><a href='run://jgdeskgrid -s'><button type='button'> Konfiguruj ...</button></a><a href='run://viewnior /usr/share/mabox/img/superclick-keyboard.gif'><button type='button'> Demo (z klawiatury) </button></a>"
KEYB="<em>z klawiatury: Super + KP_1..9</em>"
;;
*)
TITLE="SuperClick trainer"
MOUSE="hold <kbd>Super</kbd> key and click in appropriate area<br />of any window<br /><br /><em>...subsequent clicks change the size</em><br /><br /><a href='run://jgdeskgrid -s'><button type='button'> Config Menu ...</button></a><a href='run://viewnior /usr/share/mabox/img/superclick-keyboard.gif'><button type='button'> Keyboard Demo</button></a>"
KEYB="<em>with keyboard: Super + KP_1..9</em>"
;;
esac
HTML_FILE=$(mktemp /tmp/superclickXXXXX)
cat <<EOF > ${HTML_FILE}
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body{padding:0;margin:0;-webkit-user-select: none;}
#grid {display: grid;grid-template-columns: auto auto auto;gap: 1px;background-color: #113344;padding: 1px;height:100vh;}
#grid > div {background-color: rgba(255, 255, 255, 0.8);color: #113344;text-align: center;font-size: 16vh;line-height: 33vh;transition:0.3s;}
#grid > div.txt {text-align: center;position:relative;}
#grid > div.txt p {position:absolute;top:0;left:0;font-size: 2.8vh;line-height: 3.2vh;width:100%;color: #222222;}
#grid > div.txt:hover p {color: #EEEEEE;}
#grid > div:hover {background-color: #113344;color: yellow;}
</style></head>
<body><div id="grid">
<div>&nwarr;</div>
<div>&uarr;</div>
<div>&nearr;</div>
<div>&larr;</div>
<div class="txt"><p>${MOUSE}</p></div>
<div>&rarr;</div>
<div>&swarr;</div>
<div class="txt"><p>${KEYB}</p>&darr;</div>
<div>&searr;</div>
</div></body></html>
EOF
yhtml "${HTML_FILE}" "${TITLE}"
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
"") clicksnap ;;
topleft|top|topright|left|center|right|bottomleft|bottom|bottomright) moveto "$1" ;;
trainer) trainer;;
-h|--help) usage ;;
esac

50
bin/superclick-desktop Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# superclick-desktop = actions for w-Leftmouseclick event on desktop
CONFIG_FILE="$HOME/.config/mabox/superclick-desktop.conf"
if [ ! -f ${CONFIG_FILE} ]; then
cat <<EOF > ${CONFIG_FILE}
# SuperClick on desktop config file
# Sidearea width in pixels
sidewidth=300
# Commands to run on super + clik on left, center or right desktop area
left_cmd="mb-jgtools places 2>/dev/null"
center_cmd="jgdesktops -s 2>/dev/null"
right_cmd="mb-jgtools right 2>/dev/null"
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
SIDEWIDTH=${sidewidth:-0}
CENTER_CMD=${center_cmd:-"jgdesktops -s 2>/dev/null"}
LEFT_CMD=${left_cmd:-"mb-jgtools places 2>/dev/null"}
RIGHT_CMD=${right_cmd:-"mb-jgtools right 2>/dev/null"}
# Get mouse location (we need X here)
eval $(xdotool getmouselocation --shell)
# get monitor width and x-offset on current monitor (the one where pointer is)
while read -r line; do
info=$(echo $line | awk '{print $3}')
if [[ $info == primary ]]; then
info=$(echo $line | awk '{print $4}')
fi
read M_WIDTH M_X_OFF <<< $(echo $info | awk -F[x+] '{print $1, $3}')
if (( X >= M_X_OFF && X <= M_WIDTH + M_X_OFF )); then
break
fi
done < <(xrandr | grep " connected")
if [ $X -lt $((M_X_OFF+SIDEWIDTH)) ];then
bash <<< "$LEFT_CMD"
elif [ $X -gt $((M_X_OFF+M_WIDTH-SIDEWIDTH)) ];then
bash <<< "$RIGHT_CMD"
else
bash <<< "$CENTER_CMD"
fi

686
bin/t2ctl Executable file
View File

@@ -0,0 +1,686 @@
#!/bin/bash
# t2ctl - basic tint2 panel config actions
# t2ctl variable value config_file
#
T2CONFFILE="${3:-${HOME}/.config/tint2/Jaskie*.tint2rc}"
T2_CONFDIR="$HOME/.config/tint2"
SESS_FILE="$T2_CONFDIR/tint2-sessionfile"
# for Colorizer
COLORIZER_FILES="$HOME/.config/tint2/Jaskie*.tint2rc"
#array for looping
COLORIZER_TINTS=("Jaskier" "Jaskier_glyphicons")
# default file for gradients changes
T2RC="$HOME/.config/tint2/Jaskier.tint2rc"
#T2CONFFILE="$HOME/.config/tint2/mabox2111.tint2rc"
restartt2 () {
killall -SIGUSR1 tint2
}
pos () {
case "$1" in
tch)
sd "^panel_position.*$" "panel_position = top center horizontal" ${T2CONFFILE};;
bch)
sd "^panel_position.*$" "panel_position = bottom center horizontal" ${T2CONFFILE};;
tlh)
sd "^panel_position.*$" "panel_position = top left horizontal" ${T2CONFFILE};;
trh)
sd "^panel_position.*$" "panel_position = top right horizontal" ${T2CONFFILE};;
blh)
sd "^panel_position.*$" "panel_position = bottom left horizontal" ${T2CONFFILE};;
brh)
sd "^panel_position.*$" "panel_position = bottom right horizontal" ${T2CONFFILE};;
clv)
sd "^panel_position.*$" "panel_position = center left vertical" ${T2CONFFILE};;
crv)
sd "^panel_position.*$" "panel_position = center right vertical" ${T2CONFFILE};;
tlv)
sd "^panel_position.*$" "panel_position = top left vertical" ${T2CONFFILE};;
trv)
sd "^panel_position.*$" "panel_position = top right vertical" ${T2CONFFILE};;
blv)
sd "^panel_position.*$" "panel_position = bottom left vertical" ${T2CONFFILE};;
brv)
sd "^panel_position.*$" "panel_position = bottom right vertical" ${T2CONFFILE};;
esac
}
width () {
read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_size.*$" "panel_size = ${1} ${HEIGHT}" ${T2CONFFILE}
sd "^panel_shrink.*$" "panel_shrink = 0" ${T2CONFFILE}
}
height () {
read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_size.*$" "panel_size = ${WIDTH} ${1}" ${T2CONFFILE}
exeh=$(( $1 - 2 ))
sd "^execp_icon_h.*$" "execp_icon_h = ${exeh}" ${T2CONFFILE}
#new button/exec font size
btfsize=$(( $1 / 2 - 2 ))
sd "button_font = Symbols.*$" "button_font = Symbols Nerd Font ${btfsize}" ${T2CONFFILE}
sd "execp_font = Symbols.*$" "execp_font = Symbols Nerd Font ${btfsize}" ${T2CONFFILE}
# for Jaskier_glyphicons calculate rounded
round=$(( $1 / 4 - 2 ))
sd "rounded.*$" "rounded = ${round}" ~/.config/tint2/Jaskier_glyphicons.tint2rc
sd "button_padding.*$" "button_padding = ${round} ${round}" ~/.config/tint2/Jaskier_glyphicons.tint2rc
sd "execp_padding.*$" "execp_padding = ${round} ${round}" ~/.config/tint2/Jaskier_glyphicons.tint2rc
## panel padding/spacing
case "$1" in
24|28)
sd "panel_padding.*$" "panel_padding = 1 1 1" ~/.config/tint2/Jaskier_glyphicons.tint2rc
sd "taskbar_padding.*$" "taskbar_padding = 0 0 1" ~/.config/tint2/Jaskier_glyphicons.tint2rc;;
32|36|40)
sd "panel_padding.*$" "panel_padding = 2 2 2" ~/.config/tint2/Jaskier_glyphicons.tint2rc
sd "taskbar_padding.*$" "taskbar_padding = 0 0 2" ~/.config/tint2/Jaskier_glyphicons.tint2rc;;
48)
sd "panel_padding.*$" "panel_padding = 4 4 4" ~/.config/tint2/Jaskier_glyphicons.tint2rc
sd "taskbar_padding.*$" "taskbar_padding = 0 0 4" ~/.config/tint2/Jaskier_glyphicons.tint2rc;;
*):;;
esac
}
marginhor () {
read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_margin.*$" "panel_margin = ${1} ${VERT}" ${T2CONFFILE}
}
marginver () {
read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_margin.*$" "panel_margin = ${HOR} ${1}" ${T2CONFFILE}
}
paddinghor () {
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_padding.*$" "panel_padding = ${1} ${PVERT} ${SPACING}" ${T2CONFFILE}
}
paddingver () {
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_padding.*$" "panel_padding = ${PHOR} ${1} ${SPACING}" ${T2CONFFILE}
}
spacing () {
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_padding.*$" "panel_padding = ${PHOR} ${PVERT} ${1}" ${T2CONFFILE}
}
shrink () {
sd "^panel_shrink.*$" "panel_shrink = ${1}" ${T2CONFFILE}
}
autohide () {
sd "^autohide .*$" "autohide = ${1}" ${T2CONFFILE}
sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE}
}
hideheight () {
sd "^autohide_height.*$" "autohide_height = ${1}" ${T2CONFFILE}
sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE}
sd "^autohide .*$" "autohide = 1" ${T2CONFFILE}
}
icontheme () {
sd "^launcher_icon_theme.*$" "launcher_icon_theme = ${1}" ${T2CONFFILE}
}
reset () {
case "$LANG" in
pl*) LNG=pl ;;
es*) LNG=es ;;
*) LNG=en ;;
esac
cp "/usr/share/mabox/lang/${LNG}/.config/tint2/${1}" "$HOME/.config/tint2/"
}
clockline1 () {
sd "^time1_format.*$" "time1_format = ${1}" ${T2CONFFILE}
}
clockline2 () {
if [[ "$1" == "none" ]];then
sd "^time2_format.*$" "time2_format =" ${T2CONFFILE}
else
sd "^time2_format.*$" "time2_format = ${1}" ${T2CONFFILE}
fi
}
tb_icon(){
sd "^task_icon .*$" "task_icon = 1" ${T2CONFFILE}
sd "^task_text.*$" "task_text = 0" ${T2CONFFILE}
read W H <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^task_maximum_size.*$" "task_maximum_size = ${H} ${H}" ${T2CONFFILE}
}
tb_text(){
sd "^task_text.*$" "task_text = 1" ${T2CONFFILE}
sd "^task_icon .*$" "task_icon = 0" ${T2CONFFILE}
read TB_WIDTH TB_HEIGHT <<< "$(grep 'task_maximum_size' ${T2CONFFILE} | cut -d'=' -f2)"
if [[ "$TB_WIDTH" -lt "80" ]];then
if [[ "$TB_WIDTH" != "0" ]];then
sd "^task_maximum_size.*$" "task_maximum_size = 100 100" ${T2CONFFILE}
fi
fi
}
tb_both(){
sd "^task_icon .*$" "task_icon = 1" ${T2CONFFILE}
sd "^task_text.*$" "task_text = 1" ${T2CONFFILE}
read TB_WIDTH TB_HEIGHT <<< "$(grep 'task_maximum_size' ${T2CONFFILE} | cut -d'=' -f2)"
if [[ "$TB_WIDTH" -lt "80" ]];then
#notify-send.sh "mni 80" "$TB_WIDTH"
if [[ "$TB_WIDTH" != "0" ]];then
sd "^task_maximum_size.*$" "task_maximum_size = 100 100" ${T2CONFFILE}
fi
fi
}
tb_centered(){
sd "^task_centered.*$" "task_centered = ${1}" ${T2CONFFILE}
}
tb_width(){
case "$1" in
icon)
read W H <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^task_maximum_size.*$" "task_maximum_size = ${H} ${H}" ${T2CONFFILE};;
*)sd "^task_maximum_size.*$" "task_maximum_size = ${1} ${1}" ${T2CONFFILE};;
esac
}
tb_tooltip_none(){
case "$1" in
1)
sd "^task_tooltip.*$" "task_tooltip = 0" ${T2CONFFILE}
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
;;
0)
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
;;
esac
}
tb_tooltip(){
case "$1" in
1)
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
;;
0)
sd "^task_tooltip.*$" "task_tooltip = 0" ${T2CONFFILE}
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
;;
esac
}
tb_thumbnail(){
case "$1" in
1)
sd "^task_thumbnail.*$" "task_thumbnail = 1" ${T2CONFFILE}
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
;;
0)
sd "^task_thumbnail.*$" "task_thumbnail = 1" ${T2CONFFILE}
;;
esac
}
mleft(){
sd "^mouse_left.*$" "mouse_left = ${1}" ${T2CONFFILE}
}
mright(){
sd "^mouse_right.*$" "mouse_right = ${1}" ${T2CONFFILE}
}
mmiddle(){
sd "^mouse_middle.*$" "mouse_middle = ${1}" ${T2CONFFILE}
}
mup(){
sd "^mouse_scroll_up.*$" "mouse_scroll_up = ${1}" ${T2CONFFILE}
}
mdown(){
sd "^mouse_scroll_down.*$" "mouse_scroll_down = ${1}" ${T2CONFFILE}
}
mousereset(){
T2CONFFILE="${1}"
sd "^mouse_left.*$" "mouse_left = toggle_iconify" ${T2CONFFILE}
sd "^mouse_right.*$" "mouse_right = toggle" ${T2CONFFILE}
sd "^mouse_middle.*$" "mouse_middle = close" ${T2CONFFILE}
sd "^mouse_scroll_up.*$" "mouse_scroll_up = iconify" ${T2CONFFILE}
sd "^mouse_scroll_down.*$" "mouse_scroll_down = toggle_iconify" ${T2CONFFILE}
}
clock1_fontsize(){
read -a FL1 <<< "$(grep "time1_font" ${T2CONFFILE} | cut -d'=' -f2)"
L1_FONT="${FL1[@]::${#FL1[@]}-1}" # this is crazy... all array elements but last
sd "^time1_font.*$" "time1_font = ${L1_FONT} ${1}" ${T2CONFFILE}
}
clock2_fontsize(){
read -a FL2 <<< "$(grep "time2_font" ${T2CONFFILE} | cut -d'=' -f2)"
L2_FONT="${FL2[@]::${#FL2[@]}-1}" # this is crazy... all array elements but last
sd "^time2_font.*$" "time2_font = ${L2_FONT} ${1}" ${T2CONFFILE}
}
clockcolor(){
read CLR OPA <<< "$(grep "clock_font_color" ${T2CONFFILE} | cut -d'=' -f2)"
sd "clock_font_color.*$" "clock_font_color = ${1} 100" ${T2CONFFILE}
}
gradient(){
read CLR1 OPA1 <<< "$(grep "start_color" ${T2RC} | cut -d'=' -f2)"
sd "start_color .*$" "start_color = $1 ${OPA1}" ${COLORIZER_FILES}
sd "color_stop = 100 .*$" "color_stop = 100 $1 ${OPA1}" ${COLORIZER_FILES}
read CLR2 OPA2 <<< "$(grep "end_color" ${T2RC} | cut -d'=' -f2)"
sd "end_color .*$" "end_color = $2 ${OPA2}" ${COLORIZER_FILES}
sd "color_stop = 0 .*$" "color_stop = 0 $2 ${OPA2}" ${COLORIZER_FILES}
#FGCOLOR=$(pastel textcolor ${1}|pastel format hex)
#if [[ "${FGCOLOR}" == "#ffffff" ]];then
#font_color "#DDDDDD"
#allelements 0
#systray_background_id 5
#clock_background_id 5
#else
#font_color "#222222"
#allelements 0
#systray_background_id 5
#clock_background_id 5
#fi
#notify-send.sh "${FGCOLOR}" ""
}
color_reverse(){
read SBG SBGA<<< "$(grep 'start_color ' ${T2RC} | cut -d'=' -f2)"
read EBG EBGA<<< "$(grep 'end_color ' ${T2RC} | cut -d'=' -f2)"
sd "start_color .*$" "start_color = $EBG $EBGA" ${COLORIZER_FILES}
sd "color_stop = 100 .*$" "color_stop = 100 $EBG ${EBGA}" ${COLORIZER_FILES}
sd "end_color .*$" "end_color = $SBG $SBGA" ${COLORIZER_FILES}
sd "color_stop = 0 .*$" "color_stop = 0 $SBG $SBGA" ${COLORIZER_FILES}
}
gradienttype(){
sd "gradient =.*$" "gradient = ${1}" ${COLORIZER_FILES}
}
start_color(){
read SBG SBGA<<< "$(grep 'start_color ' ${T2RC} | cut -d'=' -f2)"
case "${#1}" in
7) #color
sd "start_color .*$" "start_color = $1 $SBGA" ${COLORIZER_FILES}
sd "color_stop = 100 .*$" "color_stop = 100 $1 ${SBGA}" ${COLORIZER_FILES}
;;
*)
sd "start_color .*$" "start_color = $SBG $1" ${COLORIZER_FILES}
sd "color_stop = 100 .*$" "color_stop = 100 $SBG $1" ${COLORIZER_FILES}
;;
esac
}
end_color(){
read EBG EBGA<<< "$(grep 'end_color ' ${T2RC} | cut -d'=' -f2)"
case "${#1}" in
7) #color
sd "end_color .*$" "end_color = $1 $EBGA" ${COLORIZER_FILES}
sd "color_stop = 0 .*$" "color_stop = 0 $1 ${EBGA}" ${COLORIZER_FILES}
;;
*)
sd "end_color .*$" "end_color = $EBG $1" ${COLORIZER_FILES}
sd "color_stop = 0 .*$" "color_stop = 0 $EBG $1" ${COLORIZER_FILES}
;;
esac
}
font_color(){ #all
sd "task_font_color .*$" "task_font_color = $1 100" ${COLORIZER_FILES}
sd "task_active_font_color .*$" "task_active_font_color = $1 100" ${COLORIZER_FILES}
sd "task_iconified_font_color .*$" "task_iconified_font_color = $1 60" ${COLORIZER_FILES}
sd "task_urgent_font_color .*$" "task_urgent_font_color = $1 100" ${COLORIZER_FILES}
sd "taskbar_name_font_color .*$" "taskbar_name_font_color = $1 60" ${COLORIZER_FILES}
sd "taskbar_name_active_font_color .*$" "taskbar_name_active_font_color = $1 100" ${COLORIZER_FILES}
sd "battery_font_color .*$" "battery_font_color = $1 100" ${COLORIZER_FILES}
sd "execp_font_color .*$" "execp_font_color = $1 100" ${COLORIZER_FILES}
sd "button_font_color .*$" "button_font_color = $1 100" ${COLORIZER_FILES}
sd "clock_font_color .*$" "clock_font_color = $1 100" ${COLORIZER_FILES}
}
font_color_tasks(){
sd "task_font_color .*$" "task_font_color = $1 100" ${COLORIZER_FILES}
sd "task_active_font_color .*$" "task_active_font_color = $1 100" ${COLORIZER_FILES}
sd "task_iconified_font_color .*$" "task_iconified_font_color = $1 60" ${COLORIZER_FILES}
sd "task_urgent_font_color .*$" "task_urgent_font_color = $1 100" ${COLORIZER_FILES}
sd "taskbar_name_font_color .*$" "taskbar_name_font_color = $1 60" ${COLORIZER_FILES}
sd "taskbar_name_active_font_color .*$" "taskbar_name_active_font_color = $1 100" ${COLORIZER_FILES}
}
font_color_task_active(){
sd "task_active_font_color .*$" "task_active_font_color = $1 100" ${COLORIZER_FILES}
sd "taskbar_name_active_font_color .*$" "taskbar_name_active_font_color = $1 100" ${COLORIZER_FILES}
}
font_color_buttons(){
sd "battery_font_color .*$" "battery_font_color = $1 100" ${COLORIZER_FILES}
sd "execp_font_color .*$" "execp_font_color = $1 100" ${COLORIZER_FILES}
sd "button_font_color .*$" "button_font_color = $1 100" ${COLORIZER_FILES}
}
tooltip_font_color(){
sd "tooltip_font_color .*$" "tooltip_font_color = $1 100" ${COLORIZER_FILES}
}
menucolors(){
MENUTHEME="$HOME/.config/mabox/jgobthemes/MBcolors.colorrc"
read SCLR SCLRA<<< "$(grep 'color_menu_bg ' ${MENUTHEME} | cut -d'=' -f2)"
read ECLR ECLRA<<< "$(grep 'color_menu_bg_to ' ${MENUTHEME} | cut -d'=' -f2)"
read FCLR FCLRA<<< "$(grep 'color_norm_fg ' ${MENUTHEME} | cut -d'=' -f2)"
#notify-send.sh "${SCLR} ${SCLRA}" "${ECLR} ${ECLRA}"
sd "start_color .*$" "start_color = ${SCLR} ${SCLRA}" ${COLORIZER_FILES}
sd "color_stop = 100 .*$" "color_stop = 100 ${SCLR} ${SCLRA}" ${COLORIZER_FILES}
sd "end_color .*$" "end_color = ${ECLR} ${ECLRA}" ${COLORIZER_FILES}
sd "color_stop = 0 .*$" "color_stop = 0 ${ECLR} ${ECLRA}" ${COLORIZER_FILES}
panel_background_id 10
button_background_id 11
font_color_buttons ${FCLR}
font_color_tasks ${FCLR}
}
opacityboth(){
start_color $1
end_color $1
}
postype(){
#notify-send.sh "$1" "${COLORIZER_FILES}"
case "$1" in
edge)
sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE}
#for conf in ${COLORIZER_TINTS[@]}
#do
read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_size.*$" "panel_size = 100% ${HEIGHT}" ${T2CONFFILE}
sd "^panel_shrink.*$" "panel_shrink = 0" ${T2CONFFILE}
#done
;;
float)
source ~/.config/mabox/mabox.conf
m=${floatpanel_margin:-4}
w=${floatpanel_width:-96}
sd "^panel_margin.*$" "panel_margin = $m $m" ${T2CONFFILE}
#for conf in ${COLORIZER_TINTS[@]}
#do
read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
sd "^panel_size.*$" "panel_size = ${w}% ${HEIGHT}" ${T2CONFFILE}
sd "^panel_shrink.*$" "panel_shrink = 0" ${T2CONFFILE}
#done
;;
esac
}
panel_background_id(){
sd "panel_background_id.*$" "panel_background_id = ${1}" ${COLORIZER_FILES}
# calculate tooltips colors
if [[ "$1" -lt 4 ]]; then
tooltip_background_id 3
tooltip_font_color "#11111"
#font_color "#222222"
else
tooltip_background_id 6
tooltip_font_color "#eeeeee"
#font_color "#dddddd"
fi
}
button_background_id(){
sd "button_background_id.*$" "button_background_id = ${1}" ${COLORIZER_FILES}
sd "launcher_icon_background_id.*$" "launcher_icon_background_id = ${1}" ${COLORIZER_FILES}
sd "execp_background_id.*$" "execp_background_id = ${1}" ${COLORIZER_FILES}
}
task_background_id(){
sd "task_background_id.*$" "task_background_id = ${1}" ${COLORIZER_FILES}
#sd "task_active_background_id.*$" "task_active_background_id = ${1}" ${COLORIZER_FILES}
sd "task_iconified_background_id.*$" "task_iconified_background_id = ${1}" ${COLORIZER_FILES}
}
task_active_background_id(){
sd "task_active_background_id.*$" "task_active_background_id = ${1}" ${COLORIZER_FILES}
}
task_iconified_background_id(){
sd "task_iconified_background_id.*$" "task_iconified_background_id = ${1}" ${COLORIZER_FILES}
}
task_fontsize(){
IFS=' ' read -r -a TASK_FONT <<< "$(grep '.*task_font ' ${T2CONFFILE} | cut -d"=" -f2)"
## TASK FONT FAMILY and SIZE
TASK_FSIZE="${TASK_FONT[-1]}"
TASK_FFAMILY="${TASK_FONT[@]::${#TASK_FONT[@]}-1}"
sd "task_font .*$" "task_font = ${TASK_FFAMILY} ${1}" ${T2CONFFILE}
}
task_fontfamily(){
IFS=' ' read -r -a TASK_FONT <<< "$(grep '.*task_font ' ${T2CONFFILE} | cut -d"=" -f2)"
## TASK FONT FAMILY and SIZE
TASK_FSIZE="${TASK_FONT[-1]}"
TASK_FFAMILY="${TASK_FONT[@]::${#TASK_FONT[@]}-1}"
sd "task_font .*$" "task_font = ${1} ${TASK_FSIZE}" ${T2CONFFILE}
}
taskbar_name_fontsize(){
IFS=' ' read -r -a TNAME_FONT <<< "$(grep '.*taskbar_name_font ' ${T2CONFFILE} | cut -d"=" -f2)"
## TASKBAR NAME FONT FAMILY and SIZE
TNAME_FSIZE="${TNAME_FONT[-1]}"
TNAME_FFAMILY="${TNAME_FONT[@]::${#TNAME_FONT[@]}-1}"
sd "taskbar_name_font .*$" "taskbar_name_font = ${TNAME_FFAMILY} ${1}" ${T2CONFFILE}
}
taskbar_name_fontfamily(){
IFS=' ' read -r -a TNAME_FONT <<< "$(grep '.*taskbar_name_font ' ${T2CONFFILE} | cut -d"=" -f2)"
## TASKBAR NAME FONT FAMILY and SIZE
TNAME_FSIZE="${TNAME_FONT[-1]}"
TNAME_FFAMILY="${TNAME_FONT[@]::${#TNAME_FONT[@]}-1}"
sd "taskbar_name_font .*$" "taskbar_name_font = ${1} ${TNAME_FSIZE}" ${T2CONFFILE}
}
taskbar_background_id() {
sd "taskbar_background_id.*$" "taskbar_background_id = ${1}" ${COLORIZER_FILES}
}
taskbar_active_background_id() {
sd "taskbar_active_background_id.*$" "taskbar_active_background_id = ${1}" ${COLORIZER_FILES}
}
taskbar_name_background_id() {
sd "taskbar_name_background_id.*$" "taskbar_name_background_id = ${1}" ${COLORIZER_FILES}
}
taskbar_name_active_background_id() {
sd "taskbar_name_active_background_id.*$" "taskbar_name_active_background_id = ${1}" ${COLORIZER_FILES}
}
taskbar_distribute_size(){
sd "taskbar_distribute_size.*$" "taskbar_distribute_size = ${1}" ${T2CONFFILE}
}
tasks_align(){
sd "task_align .*$" "task_align = ${1}" ${T2CONFFILE}
}
taskbar_name(){
sd "taskbar_name .*$" "taskbar_name = ${1}" ${T2CONFFILE}
}
systray_background_id(){
sd "systray_background_id.*$" "systray_background_id = ${1}" ${COLORIZER_FILES}
}
clock_background_id(){
sd "clock_background_id.*$" "clock_background_id = ${1}" ${COLORIZER_FILES}
}
tooltip_background_id(){
sd "tooltip_background_id.*$" "tooltip_background_id = ${1}" ${COLORIZER_FILES}
}
launcher_background_id(){
sd "launcher_background_id.*$" "launcher_background_id = ${1}" ${COLORIZER_FILES}
}
allelements(){
button_background_id "$1"
task_background_id "$1"
task_active_background_id "$1"
taskbar_active_background_id "$1"
taskbar_background_id "$1"
taskbar_name_active_background_id "$1"
taskbar_name_background_id "$1"
launcher_name_background_id "$1"
systray_background_id "$1"
clock_background_id "$1"
}
preset(){
case "$1" in
bright)
panel_background_id 3
allelements 0
task_background_id 1
task_active_background_id 4
taskbar_name_background_id 1
taskbar_name_active_background_id 4
systray_background_id 4
clock_background_id 4
font_color '#222222'
clockcolor "#111111"
;;
brightened2)
panel_background_id 2
allelements 0
task_background_id 1
task_active_background_id 3
taskbar_name_background_id 1
taskbar_name_active_background_id 3
systray_background_id 4
clock_background_id 4
font_color '#111111'
;;
brightened)
panel_background_id 1
allelements 0
task_active_background_id 4
taskbar_name_active_background_id 4
systray_background_id 4
clock_background_id 4
font_color '#dddddd'
;;
darkened)
panel_background_id 4
allelements 0
task_active_background_id 4
taskbar_name_active_background_id 4
systray_background_id 4
clock_background_id 4
font_color '#bbbbbb'
;;
darkened2)
panel_background_id 5
allelements 0
task_active_background_id 5
taskbar_name_active_background_id 5
systray_background_id 5
clock_background_id 5
font_color '#bbbbbb'
;;
dark)
panel_background_id 6
allelements 0
task_background_id 1
font_color '#dddddd'
clock_background_id 6
clockcolor "#f4a300"
;;
translighter)
panel_background_id 0
allelements 0
task_active_background_id 1
taskbar_background_id 0
taskbar_active_background_id 0
taskbar_name_background_id 0
taskbar_name_active_background_id 1
font_color '#dddddd'
;;
transdarker)
panel_background_id 0
allelements 0
task_active_background_id 4
taskbar_background_id 0
taskbar_active_background_id 0
taskbar_name_background_id 0
taskbar_name_active_background_id 4
clock_background_id 5
systray_background_id 5
font_color '#222222'
;;
grad_dark)
panel_background_id 7
gradient "#383838" "#222222"
opacityboth 96
allelements 0
task_active_background_id 7
task_background_id 1
taskbar_active_background_id 4
taskbar_name_background_id 7
taskbar_name_active_background_id 0
systray_background_id 7
clock_background_id 7
clockcolor "#3cd425"
;;
esac
}
switchto(){
case "$1" in
default) echo "${T2_CONFDIR}/Jaskier.tint2rc" > "${SESS_FILE}";;
glyphicons) echo "${T2_CONFDIR}/Jaskier_glyphicons.tint2rc" > "${SESS_FILE}";;
basic) echo "${T2_CONFDIR}/Jaskier_basic.tint2rc" > "${SESS_FILE}";;
*)
#notify-send.sh "AAA" "${1}"
if [ -f $1 ];then
echo "${1}" > "${SESS_FILE}"
fi
;;
esac
killall tint2
mb-tint2-session
}
case "$1" in
position) pos "$2";;
width) width "$2" ;;
height) height "$2" ;;
shrink) shrink "$2" ;;
marginh) marginhor "$2" ;;
marginv) marginver "$2" ;;
paddingh) paddinghor "$2" ;;
paddingv) paddingver "$2" ;;
spacing) spacing "$2" ;;
autohide) autohide "$2" ;;
hideheight) hideheight "$2" ;;
icontheme) icontheme "$2" ;;
clockline1) clockline1 "$2";;
clockline2) clockline2 "$2";;
tb_icon)tb_icon "$2";;
tb_text)tb_text "$2";;
tb_both)tb_both "$2";;
tb_centered)tb_centered "$2";;
tb_width)tb_width "$2";;
tb_tooltip_none)tb_tooltip_none "$2";;
tb_tooltip)tb_tooltip "$2";;
tb_thumbnail)tb_thumbnail "$2";;
mleft)mleft "$2";;
mright)mright "$2";;
mmiddle)mmiddle "$2";;
mup)mup "$2";;
mdown)mdown "$2";;
mousereset)mousereset "$2";;
reset) reset "$2" ;;
clock1_fontsize) clock1_fontsize "$2";;
clock2_fontsize) clock2_fontsize "$2";;
clockcolor) clockcolor "$2";;
gradient) gradient "$2" "$3";;
color_reverse) color_reverse;;
gradienttype) gradienttype "$2";;
start_color) start_color "$2";;
end_color) end_color "$2";;
font_color) font_color "$2";;
font_color_tasks)font_color_tasks "$2";;
font_color_task_active)font_color_task_active "$2";;
font_color_buttons)font_color_buttons "$2";;
tooltip_font_color) tooltip_font_color "$2";;
menucolors)menucolors;;
opacityboth)opacityboth "$2";;
postype) postype "$2";;
panel_background_id)panel_background_id "$2";;
button_background_id)button_background_id "$2";;
launcher_background_id)launcher_background_id "$2";;
task_background_id)task_background_id "$2";;
task_active_background_id)task_active_background_id "$2";;
task_iconified_background_id)task_iconified_background_id "$2";;
task_fontsize)task_fontsize "$2";;
task_fontfamily)task_fontfamily "$2";;
taskbar_background_id)taskbar_background_id "$2";;
taskbar_active_background_id)taskbar_active_background_id "$2";;
taskbar_name_background_id)taskbar_name_background_id "$2";;
taskbar_name_active_background_id)taskbar_name_active_background_id "$2";;
taskbar_name_fontsize)taskbar_name_fontsize "$2";;
taskbar_name_fontfamily)taskbar_name_fontfamily "$2";;
taskbar_distribute_size)taskbar_distribute_size "$2";;
tasks_align)tasks_align "$2";;
taskbar_name)taskbar_name "$2";;
systray_background_id)systray_background_id "$2";;
clock_background_id)clock_background_id "$2";;
tooltip_background_id)tooltip_background_id "$2";;
allelements) allelements "$2";;
preset) preset "$2";;
switchto)switchto "$2";;
*) : ;;
esac
restartt2

45
bin/transparent-cava Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
#: Usage: transparent-cava (height in pixels) (width full or half)
#: example transparent-cava 100 full
#: default is 200px height and half width
CONFIG_DIR="$HOME/.config/terminator"
CONFIG_FILE="$CONFIG_DIR/cava-transparent"
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
[global_config]
dbus = False
[keybindings]
[profiles]
[[default]]
allow_bold = False
background_darkness = 0.0
background_type = transparent
cursor_blink = False
cursor_color = "#aaaaaa"
font = Sans 2
show_titlebar = False
scrollbar_position = hidden
scroll_on_keystroke = False
use_custom_command = True
custom_command = cava
use_system_font = False
[layouts]
[plugins]
EOF
fi
CAVA_HEIGHT=${1:-200}
CAVA_WIDTH=${2:-half}
WIDTH=$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)
HEIGHT=$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)
TOP=$((HEIGHT-CAVA_HEIGHT))
LEFT=0
if [ "$CAVA_WIDTH" != "full" ];then
LEFT=$((WIDTH/4))
WIDTH=$((WIDTH/2))
else
:
fi
terminator -b -g "${CONFIG_FILE}" -T cavatransparent --geometry "${WIDTH}x${CAVA_HEIGHT}+${LEFT}+${TOP}" -i amarok_playcount

86
bin/yautostart Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/bash
# yautostart: Mabox XDG Autostart GUI script
# Copyright (C) 2019 napcok <napcok@gmail.com>
#
case $LANG in
pl*)
TITLE="Edytor autostartu XDG"
DESC="Wybierz programy/usługi, które mają być uruchamiane autamatycznie\nwraz z sesją OpenBox. <a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Pomoc (online)</a>"
ENABLE="wł"
FILE="Plik"
NAME="Nazwa"
COMMENT="Komentarz"
NO_DESC=""
CANCEL="--button=Anuluj:1"
OK="--button=Zastosuj:0"
;;
es*)
TITLE="XDG Autostart Editor"
DESC="Elegir apps o servicios para un reinicio en sesión Openbox.\n<a href='https://manual.maboxlinux.org/es/configuration/autostart/'>Info (online)</a>"
ENABLE="ejecutar"
FILE="Archivo"
NAME="Nombrar"
COMMENT="Comentar"
NO_DESC=""
CANCEL="--button=Cancelar:1"
OK="--button=Aceptar:0"
;;
*)
TITLE="Mabox XDG Autostart Editor"
DESC="Choose apps/services to autostart with OpenBox session.\n<a href='https://manual.maboxlinux.org/en/configuration/autostart/'>Info (online)</a>"
ENABLE="run"
FILE="File"
NAME="Name"
COMMENT="Comment"
NO_DESC=""
CANCEL="--button=Cancel:1"
OK="--button=OK:0"
;;
esac
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
# Copy only new files from /etc/xdg/autostart/
mkdir -p $config_dir/autostart
#remove pamac-tray-budgie
rm $config_dir/autostart/pamac-tray-budgie.desktop
rsync -aq --ignore-existing --exclude="pamac-tray-budgie.desktop" /etc/xdg/autostart/ $config_dir/autostart/
# check if line starting with Hidden exist, if not add Hidden=false
for f in $config_dir/autostart/*.desktop; do
grep -q "Hidden=" $f && echo "yes" || echo "Hidden=false" >> $f
done
results=$(mktemp --tmpdir autostart.XXXXXXXXXX)
for f in $config_dir/autostart/*.desktop; do
[ "$(grep -m 1 -e '^[[:blank:]]*Hidden' $f | cut -d = -f 2)" == "true" ] && echo false || echo true
echo $f
#grep -m 1 -e '^[[:blank:]]*Name=' $f | cut -d = -f 2
name=$(grep -m 1 -e '^[[:blank:]]*Name=' $f | cut -d = -f 2)
echo "<b>$name</b>"
#grep -m 1 -e '^[[:blank:]]*Exec' $f | cut -d = -f 2
comment=$(grep -m 1 -e '^[[:blank:]]*Comment=' $f | cut -d = -f 2)
[ ! -z "$comment" ] && echo "<i>${comment/&/&amp;}</i>" || echo "$NO_DESC"
done | yad --window-icon=distributor-logo-mabox --width=640 --height=500 --title="$TITLE" --image="gtk-execute" --uri-handler=xdg-open \
--text="$DESC" --list --print-all --bool-fmt="t" \
--checklist --column="$ENABLE:CHK" --column="$FILE:HD" --column="$NAME" --column="$COMMENT" --tooltip-column=4 $CANCEL $OK > $results
if [[ ${PIPESTATUS[1]} -eq 0 ]]; then
i=0
cat $results | while read line; do
eval $(echo $line | awk -F'|' '{printf "export HIDDEN=\"%s\" FILENAME=\"%s\"", $1, $2 }')
[ $HIDDEN == "true" ] && HIDDEN="false" || HIDDEN="true"
echo "Hidden=$HIDDEN, File: $FILENAME"
sed -i'.temp' -e 's/^Hidden.*$/Hidden='"$HIDDEN"'/g' $FILENAME
rm $FILENAME.temp
((i++))
done
unset NAME HIDDEN FILENAME comment
fi
rm -f $results
exit 0

20
bin/yhtml Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
file=${1}
title=${2:-"Mabox Linux Doc"}
width=${3:-800}
height=${4:-600}
stdbuf -oL -e0 yad --title="${title}" --window-icon=mbcc --borders=0 \
--width=${width} --height=${height} \
--no-buttons --no-escape --html --uri="${1}" --print-uri \
| while read -r line; do
case ${line%:*} in
https) xdg-open "${line}" &;;
run) ${line##*//} &;;
config) geany "$HOME/${line#*//}" &;;
term) terminator -e "${line#*//}" &;;
termo) terminator -e "${line#*//};bash" &;;
*) echo "No URI";;
esac
done