wallchanger

master
Daniel Napora 2021-05-30 01:51:41 +02:00
parent a22bf909ca
commit 3d81bc66ba
4 changed files with 103 additions and 100 deletions

View File

@ -1,96 +0,0 @@
#!/bin/bash
### clicksnap - click on the appropriate area of the window to snap it in a given direction.
# Works with active and inactive windows
# Author: Daniel Napora <napcok@gmail.com>
# https://maboxlinux.org
#
CONFIG_DIR="$HOME/.config/deskgrid"
CONFIG_FILE="$CONFIG_DIR/deskgrid.conf"
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)
grid_x=16
# Grid rows (6 12 16)
grid_y=12
#
titlebar_height=18
#Notifications true or false
enable_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}
TITLEBAR_HEIGHT=${titlebar_height:-18}
eval $(xdotool getmouselocation --shell)
Mouse_x="$X"
Mouse_y="$Y"
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
if xwininfo -id $CHILD_ID -wm |grep Undecorated ; then # Undecorated
T="0"
else # Decorated
T="$TITLEBAR_HEIGHT"
fi
## OUTER GAP
if [[ "$show_outer_gap" == "true" ]]; then OUT_GAP="$GAP" ; else OUT_GAP="0" ; fi
echo "OUT_GAP: $OUT_GAP"
eval $(xdotool getwindowgeometry --shell $WINDOW)
Win_x="$X"
Win_y="$Y"
Win_width="$WIDTH"
Win_height="$HEIGHT"
Rel_x="$((Mouse_x-Win_x))"
Rel_y="$((Mouse_y-Win_y))"
pos_x="$(((Mouse_x-Win_x)/(Win_width/3)))"
pos_y="$(((Mouse_y-Win_y)/(Win_height/3)))"
POS_CODE="$pos_x$pos_y"
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#*,}"
case $POS_CODE in
00) # top-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
10) # top
W=$((AVAIL_X-OUT_GAP*2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
20) # top-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+OUT_GAP));;
01) # left
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y-T-OUT_GAP*2)) X=$((0+OFF_X+OUT_GAP)) Y=$((0+OFF_Y+OUT_GAP));;
11) # center
W=$((AVAIL_X/8*6-OFF_X)) H=$((AVAIL_Y/8*6-T)) X=$((AVAIL_X/8+OFF_X/2)) Y=$((AVAIL_Y/8+OFF_Y/2));;
21) # right
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y-T-OUT_GAP*2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+OUT_GAP));;
02) # bottom-left
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
12) # bottom
W=$((AVAIL_X-OUT_GAP*2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((0+OFF_X+OUT_GAP)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
22) # bottom-right
W=$((AVAIL_X/2-OUT_GAP-GAP/2)) H=$((AVAIL_Y/2-T-OUT_GAP-GAP/2)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
esac
xdotool windowsize $WINDOW $W $H
xdotool windowmove $WINDOW $X $Y
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi

65
bin/mbscreenlocker 100755
View File

@ -0,0 +1,65 @@
#!/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=betterlockscreen
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
lock() {
if [[ $screenlocker == "betterlockscreen" ]]; then
betterlockscreen -l $effect
else
i3lock -B 2 -k
fi
}
cache() {
case $LANG in
pl*)
TITLE="Tworzenie obrazków dla blokady ekranu"
TEXT="\nCierpliwości...\nto może chwilkę potrwać.."
TITLE2="Gotowe"
TEXT2="\n<b>W-l</b> aby zablokować ekran\n<b>W-A-s</b>aby konfigurować Tapety/Blokadę ekranu."
;;
*)
TITLE="Caching images for faster screen locking"
TEXT="\nPlease wait...\nthis might take few seconds..."
TITLE2="Done"
TEXT2="All required changes have been applied."
;;
esac
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"
}
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
-c|cache) cache;;
-h|--help) usage;;
*) lock;;
esac
exit 0

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CONFIG_DIR="$HOME/.config/chwp" CONFIG_DIR="$HOME/.config/mbwallpaper"
CONFIG_FILE="$CONFIG_DIR/chwp.conf" CONFIG_FILE="$CONFIG_DIR/mbwallpaper.conf"
WALLPAPERS_LIST="$CONFIG_DIR/wplist" WALLPAPERS_LIST="$CONFIG_DIR/wplist"
# Make config directory if not exist # Make config directory if not exist
@ -48,6 +48,18 @@ one() {
} }
choose() { choose() {
case $LANG in
pl*)
TITLE="Wybierz tapetę"
TEXT="\nUżyj <b>strzałek</b> lub <b>kółka myszy</b> by nawigować.\n<b>Enter</b> by ustawić tapetę.\n<b>Esc</b> by wyjść."
;;
*)
TITLE="Select Wallpaper"
TEXT="\nUse <b>Arrows</b> or <b>mousewheel</b> to navigate.\n<b>Enter</b> to set wallpaper.\n<b>Esc</b> to quit."
;;
esac
SCREENSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $4}') SCREENSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $4}')
W="${SCREENSIZE%x*}" W="${SCREENSIZE%x*}"
H="${SCREENSIZE#*x}" H="${SCREENSIZE#*x}"
@ -55,8 +67,8 @@ choose() {
FH=$((H/4)) FH=$((H/4))
X="40" X="40"
Y=$((H-FH-40)) Y=$((H-FH-40))
notify-send.sh -u normal -i image "Select wallpaper" "\nUse <b>Arrows</b> or <b>mousewheel</b> to navigate.\n<b>Enter</b> to set wallpaper.\n<b>Esc</b> to quit." notify-send.sh -u normal -i emblem-photos "$TITLE" "$TEXT"
feh -B "#4D4D4D" -N -x --scale-down -E ${FH} -y ${FW} -^ "Enter=select, Arrows=next,prev" -g ${FW}x${FH}+${X}+${Y} ${wallpaper_dir} -A "${command} %f" feh -B "#4D4D4D" -N -x --scale-down -E ${FH} -y ${FW} -^ "Enter=select, Arrows=next,prev" -g ${FW}x${FH}+${X}+${Y} ${wallpaper_dir} -A "${command} '%f'"
} }
slideshow() { slideshow() {

View File

@ -0,0 +1,22 @@
#!/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
mbwallpaper &
mbwallpaper_pid=$!
notify-send.sh -i emblem-photos "$TITLE" "$TEXT"
yad --notification --image emblem-photos --text "$CLICK"
kill $mbwallpaper_pid
wait $mbwallpaper_pid