Page 1 of 1
Mounter_Rotator
Posted: Wed May 05, 2021 3:34 am
by stemsee
This dual function script, mounts and unmounts partitions, and also rotates screen/touchpad/touchScreen...
Creates mount directory in /Here is a significant update to Mounter_Rotator_2.0.
UPDATE!!: In this update I have added functions for window placement (top,bottom,left,right,topleft,topright,bottomleft.bottomright) using wmctrl (dependency).
The menu now has an entry to add my custom keycodes to sven, and restart sven.
To rotate screen press WinKey + arrows. To place windows in screen halves press Ctrl + arrows. To place selected window in quarter screen positions press Alt + arrows. The script does not add keycodes if such codes are already used. In that case you will need to change keycodes manually first.
- mounter_rotator.png (50.8 KiB) Viewed 2375 times
Mounter_Rotator_3.0
Code: Select all
#!/bin/sh
# Copyright (C) 2014 stemsee
# gpl v3 license applies for personal use
#[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
export lng="$2"
function BH
{
YY=$(((YY / 2) - 33))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function TH
{
YY=$((YY / 2))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function RH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function LHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LHD
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function RHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function RHD
{
XX=$((XX / 2))
YY=$((YY / 2 ))
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
}
function add2sven
{
LEFT="[113:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Left')
command=/root/Startup/rotate left
comment=Rotate Left\n"
[[ -z $(grep '113:64' /root/.sven/key_config) ]] && echo -e "$LEFT" >> /root/.sven/key_config
RIGHT="[114:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Right')
command=/root/Startup/rotate right
comment=Rotate Right\n"
[[ -z $(grep '114:64' /root/.sven/key_config) ]] && echo -e "$RIGHT" >> /root/.sven/key_config
INVERTED="[111:64]
type=cmd
enable=1
description=$(gettext 'Rotate Inverted')
command=/root/Startup/rotate inverted
comment=Rotate Inverted\n"
[[ -z $(grep '1116:4' /root/.sven/key_config) ]] && echo -e "$INVERTED" >> /root/.sven/key_config
NORMAL="[116:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen normal')
command=/root/Startup/rotate normal
comment=Rotate Screen Normal\n"
[[ -z $(grep '116:64' /root/.sven/key_config) ]] && echo -e "$NORMAL" >> /root/.sven/key_config
LH="[113:4]
type=cmd
enable=1
description=$(gettext 'Left Half of Screen')
command=/root/Startup/rotate LH
comment=Move Window to Left\n"
[[ -z $(grep '113:4' /root/.sven/key_config) ]] && echo -e "$LH" >> /root/.sven/key_config
RH="[114:4]
type=cmd
enable=1
description=$(gettext 'Right Half of Screem')
command=/root/Startup/rotate RH
comment=Move Window To Right\n"
[[ -z $(grep '114:4' /root/.sven/key_config) ]] && echo -e "$RH" >> /root/.sven/key_config
TH="[111:4]
type=cmd
enable=1
description=$(gettext 'Top Half of Screen')
command=/root/Startup/rotate TH
comment=Move to Top Half\n"
[[ -z $(grep '111:4' /root/.sven/key_config) ]] && echo -e "$TH" >> /root/.sven/key_config
BH="[116:4]
type=cmd
enable=1
description=$(gettext 'Bottom Half of Screen')
command=/root/Startup/rotate BH
comment=Move Window To Bottom\n"
[[ -z $(grep '116:4' /root/.sven/key_config) ]] && echo -e "$BH" >> /root/.sven/key_config
RHU="[111:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Top')
command=/root/Startup/rotate RHU
comment=\n"
[[ -z $(grep '111:8' /root/.sven/key_config) ]] && echo -e "$RHU" >> /root/.sven/key_config
RHD="[114:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Down')
command=/root/Startup/rotate RHD
comment=\n"
[[ -z $(grep '114:8' /root/.sven/key_config) ]] && echo -e "$RHD" >> /root/.sven/key_config
LHU="[113:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Top')
command=/root/Startup/rotate LHU
comment=\n"
[[ -z $(grep '113:8' /root/.sven/key_config) ]] && echo -e "$LHU" >> /root/.sven/key_config
LHD="[116:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Down')
command=/root/Startup/rotate LHD
comment=\n"
[[ -z $(grep '116:8' /root/.sven/key_config) ]] && echo -e "$LHD" >> /root/.sven/key_config
sven -k
sven &
};export -f add2sven
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "icon:left.png" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "icon:right.png" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=$(echo "$events" | cut -f2 -d' ')
pad=$(echo "$events" | cut -f1 -d' ')
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "icon:inverted.png" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "icon:normal.png" >>/tmp/RPIPE
}; export -f normal
function rotate_flipx {
xrandr -x
};export -f rotate_flipx
function rotate_flipy {
xrandr -y
};export -f rotate_flipy
function rotate_flip_normal {
xrandr -o normal
};export rotate_flip_normal
function driveumnt {
umount /dev/"$1" /mnt/"$1"
DrivIcons
echo "icon:/usr/share/pixmaps/driveOFF.png" >>/tmp/DRIVES
};export -f driveumnt
function drivemnt {
mount /dev/"$1" /mnt/"$1"
DrivIcons
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
};export -f drivemnt
function DrivIcons {
mkfifo -m755 /tmp/DRIVES
exec 8<> /tmp/DRIVES
cnt=1
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
INFO=$(lsblk "$i" | tail -n1)
SWAP=$(cat /proc/swaps | tail -n+1 | cut -f1 -d' ' | grep $i)
[ "$SWAP" ] && i="SWAP"
case "$i" in
'/dev/sd'*|'/dev/mmcblk'*) DRIVENAME=$(basename $i)
export MENU$cnt="$(gettext 'mount') $INFO!bash -c \"drivemnt $DRIVENAME;rox /mnt/$DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext 'UnMount') $DRIVENAME!bash -c \"driveumnt $DRIVENAME \"!/usr/share/pixmaps/driveOFF.png||";;
SWAP) DRIVENAME=$(echo $INFO | cut -f1 -d' ')
export MENU$cnt="$(gettext 'Swap On') $INFO!bash -c \"swapon /dev/$DRIVENAME;DivvIcons \"!/usr/share/pixmaps/driveON.png|$(gettext 'Swap Off') $DRIVENAME!bash -c \"swapoff /dev/$DRIVENAME;DrivIcons \"!/usr/share/pixmaps/driveOFF.png||"
;;
esac
export cnt=$((cnt + 1))
unset SWAP
done
yad --notification --listen --text="$(gettext "Storage Devices")" --tray-icon="/usr/share/pixmaps/driveON.png" --command="bash -c \"rox /mnt/ \"" --menu="$(gettext 'Drive Mounting')|||$MENU12$MENU11$MENU10$MENU9$MENU8$MENU7$MENU6$MENU5$MENU4$MENU3$MENU2$MENU1|Close!quit!gtk-cancel" <& 8 &
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
}; export -f DrivIcons
function on_exit (){
rm -f /tmp/RPIPE
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
rm -f /tmp/$(basename $i)
done
}
export -f on_exit
trap 'on_exit' EXIT
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export HANDEL="$RANDOM"
mkfifo -m755 /tmp/$HANDEL
exec 1<> /tmp/$HANDEL
function maingui (){
export WINDOWTITLE="$(gettext 'Mounter_Rotator')"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="$(gettext 'Mount'):FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="$(gettext 'Partition'):CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="$(gettext 'Mount Dir'):CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="$(gettext 'un-Mount'):FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="$(gettext 'Xinput Events'):TXT" "`xinput`" \
--field="$(gettext 'touchpad event id='):NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="$(gettext 'Touchscreen event id='):NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="$(gettext 'Store Events'):FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--field="$(gettext 'Rotate left'):FBTN" "bash -c \"left \"" \
--field="$(gettext 'Rotate right'):FBTN" "bash -c \"right \"" \
--field="$(gettext 'Rotate normal'):FBTN" "bash -c \"normal \"" \
--field="$(gettext 'Rotate inverted'):FBTN" "bash -c \"inverted \"" \
--field="$(gettext 'Mirror X axis'):FBTN" "bash -c 'rotate_flipx'" \
--field="$(gettext 'Mirror Y axis'):FBTN" "bash -c 'rotate_flipy'" \
--field="$(gettext 'Create Drive Icons'):FBTN" "bash -c 'DrivIcons'" \
--no-buttons \
--title="$(gettext "$WINDOWTITLE")" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
if [ ! -f /tmp/ROTATE ]; then
yad --notification --listen --text="$(gettext 'Click then position cursor to get right click menu')" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c 'sleep 4; xdotool click 3'" --menu="$(gettext 'Storage Devices')!bash -c DrivIcons!/usr/share/pixmaps/driveON.png|$(gettext 'Screen Rotation Win-Key + arrows')|$(gettext 'Window Placement Alt/Ctrl + arrows')|$(gettext 'Rotate Left')!bash -c left!/usr/share/pixmaps/left.png|$(gettext 'Rotate right')!bash -c right!/usr/share/pixmaps/right.png|$(gettext 'Rotate Inverted')!bash -c inverted!/usr/share/pixmaps/inverted.png|$(gettext 'Rotate Normal')!bash -c normal!/usr/share/pixmaps/normal.png|$(gettext 'Mirror X axis')!bash -c 'rotate_flipx'!/usr/share/pixmaps/flipx.png|$(gettext 'Mirror Y axis')!bash -c 'rotate_flipy'!/usr/share/pixmaps/flipy.png|$(gettext 'Open Graphical User Interface')!bash -c maingui!gtk-open|$(gettext 'Write key-combos to') sven!bash -c '/root/Startup/rotate sven'!gtk-save|$(gettext 'Close')!quit!gtk-cancel" <& 1 &
echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/$HANDEL
[ ! -f /tmp/ROTATE ] && touch /tmp/ROTATE
fi
case $1 in
left) $1
;;
right) $1
;;
inverted) $1
;;
normal) $1
;;
BH) $1
;;
TH) $1
;;
RH) $1
;;
LH) $1
;;
LHD) $1
;;
LHU) $1
;;
RHD) $1
;;
RHU) $1
;;
sven) add2sven
;;
esac
Re: Mounter_Rotator
Posted: Wed May 05, 2021 8:14 am
by stemsee
an update ... more mount directories /media /aufs /mnt with full path! find partitions with fdisk and blkid
Code: Select all
bin/sh
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
mkfifo -m755 /tmp/RPIPE
exec 3<> /tmp/RPIPE
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "tooltip:left" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "tooltip:right" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "tooltip:inverted" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "tooltip:normal" >>/tmp/RPIPE
}; export -f normal
function on_exit (){
rm -f /tmp/RPIPE
}
export -f on_exit
trap "bash -c 'on_exit'" EXIT
( sleep 1; echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/RPIPE ) &
function maingui (){
export WINDOWTITLE="Mounter_Rotator"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="Mount:FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="Partition:CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="Mount Dir:CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="un-Mount:FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="Xinput Events:TXT" "`xinput`" \
--field="touchpad event id=:NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="Touchscreen event id=:NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="Rotate left:FBTN" "bash -c \"left \"" \
--field="Rotate right:FBTN" "bash -c \"right \"" \
--field="Rotate normal:FBTN" "bash -c \"normal \"" \
--field="Rotate inverted:FBTN" "bash -c \"inverted \"" \
--field="Store Events:FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--no-buttons \
--title="$WINDOWTITLE" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
yad --notification --listen --text="Rotate Screen: left Click for Normal Orientation" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c normal" --menu="Rotate Left!bash -c left!/usr/share/pixmaps/left.png|Rotate right!bash -c right!/usr/share/pixmaps/right.png|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/inverted.png|GUI!bash -c maingui!gtk-open|Close!quit!gtk-cancel" <&3
- mr.png (66.9 KiB) Viewed 2352 times
Re: Mounter_Rotator
Posted: Wed May 05, 2021 9:50 am
by taersh
Re: Mounter_Rotator
Posted: Wed May 05, 2021 3:53 pm
by Flash
taersh wrote: ↑Wed May 05, 2021 9:50 am
What's this needed for?
I said the same thing about computers when they first hit the market.
Re: Mounter_Rotator
Posted: Wed May 05, 2021 7:03 pm
by stemsee
taersh wrote: ↑Wed May 05, 2021 9:50 am
What's this needed for?
it helps constipation, which clears your mind to make sound judgements so increasing your wealth creation ability when shorting crypto currencies!
Re: Mounter_Rotator
Posted: Mon Sep 20, 2021 1:34 am
by BarryK
@stemsee
Very interesting!
Would you mind posting the png images also?
Re: Mounter_Rotator
Posted: Mon Sep 20, 2021 1:12 pm
by bigpup
Please post this script as a file we can download.
A pet package would be even better.
It is hard to get a good download, of a script, that you have to scroll thru to get it all, to paste in a script file, you make.
Re: Mounter_Rotator
Posted: Mon Sep 20, 2021 6:10 pm
by greengeek
bigpup wrote: ↑Mon Sep 20, 2021 1:12 pm
It is hard to get a good download, of a script, that you have to scroll thru to get it all, to paste in a script file, you make.
Above the code window is a "select all" button. If you click that then use Ctrl+C it becomes much easier to copy across to a new script.
Re: Mounter_Rotator
Posted: Mon Sep 20, 2021 7:33 pm
by bigpup
Never noticed that option.
Seems we never see what is right in front of us
Thanks!!
Still would be better as a pet package or file to download.
How many of us, really know how to turn that script, into a working file, you can run.
Re: Mounter_Rotator
Posted: Mon Sep 20, 2021 11:55 pm
by geo_c
bigpup wrote: ↑Mon Sep 20, 2021 7:33 pm
Never noticed that option.
Seems we never see what is right in front of us
Thanks!!
Still would be better as a pet package or file to download.
How many of us, really know how to turn that script, into a working file, you can run.
It's not as hard as one might think. Paste the code into a text file. Right click on the file in ROX, and choose File>Permissions, a dialogue will pop with the <a + x (Make executable/searchable> option in the field labeled Command: Choose the -Yes- button. Now the text file is a script, and it will run with a click in ROX. If you'd like to type the script name in a terminal to run, move the file to /root/my-applications and the system will look for executable scripts there.
Re: Mounter_Rotator
Posted: Tue Sep 21, 2021 3:23 am
by bigpup
That is info that needs to be in the first post.
I do it in a slightly different way.
But the info is not for me, but a lot of new Puppy users and others.
Posting it as already a script file, makes it easy to use by all.
Re: Mounter_Rotator
Posted: Wed Sep 22, 2021 3:21 pm
by geo_c
bigpup wrote: ↑Tue Sep 21, 2021 3:23 am
That is info that needs to be in the first post.
I do it in a slightly different way.
But the info is not for me, but a lot of new Puppy users and others.
Posting it as already a script file, makes it easy to use by all.
That's kind of funny, because I didn't look closely and I thought one of the other members made those comments, so I thought I was being helpful! If I had noticed it was you, I probably would have figured out what you were actually saying.
Re: Mounter_Rotator
Posted: Thu Sep 23, 2021 4:17 pm
by bigpup
I probably did not say that very well!
It still was some very helpful info by you!!
Re: Mounter_Rotator
Posted: Sat Sep 25, 2021 6:06 am
by stemsee
here is a complete sfs. actual script is in /root/Startup
Re: Mounter_Rotator
Posted: Sun Jun 12, 2022 4:19 pm
by stemsee
Here is a significant update to Mounter_Rotator_2.0.
In this update I have added functions for window placement (top,bottom,left,right,topleft,topright,bottomleft.bottomright) using wmctrl (dependency).
The menu now has an entry to add my custom keycodes to sven, and restart sven.
To rotate screen press WinKey + arrows. To place windows in screen halves press Ctrl + arrows. To place selected window in quarter screen positions press Alt + arrows. The script does not add keycodes if such codes are already used. In that case you will need to change keycodes manually first.
Re: Mounter_Rotator
Posted: Thu Jun 01, 2023 10:47 pm
by stemsee
Mounter_Rotator has just been upgraded. As I no longer work with a pinboard my desktop isn't iconifiable. So I added a little code to create tray notification menus with yad for connected drives, one per drive. There are mounted and umounted icons. Also right-click menu. I'm re-using the /tmp/udev-fatdog-drive-icon/devices files for tray text and drive availability. So essentially it's fatdog only.
Re: Mounter_Rotator
Posted: Thu Jun 01, 2023 11:41 pm
by geo_c
stemsee wrote: ↑Thu Jun 01, 2023 10:47 pm
As I no longer work with a pinboard my desktop isn't iconifiable. So I added a little code to create tray notification menus with yad for connected drives, one per drive.
At the moment I'm not working with a pinboad either because I'm running KLV-Spectrwm. It's a tiling window manager that uses Rox for the pinboard like a pup, but it can be turned off in the window manager config file, which I did.
It's pretty fun.
Spectrwm has no tray notifications either, so it's all keystrokes after booting until a window is opened, then the mouse may come into play.
Re: Mounter_Rotator
Posted: Fri Jun 02, 2023 10:01 am
by stemsee
I have a mouse from the get go. I'm using lxqt-panel for my initial interface. I then open a terminal to fire up icewm, which seems to have similar functionality to your spectrwm.
Here is the code in case you can use the tray icon function
Code: Select all
#!/bin/sh
# Copyright (C) 2014 stemsee
# gpl v3 license applies for personal use
#[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
function BH
{
YY=$(((YY / 2) - 33))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function TH
{
YY=$((YY / 2))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function RH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function LHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LHD
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function RHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function RHD
{
XX=$((XX / 2))
YY=$((YY / 2 ))
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
}
function add2sven
{
LEFT="[113:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Left')
command=/root/Startup/rotate left
comment=Rotate Left\n"
[[ -z $(grep '113:64' /root/.sven/key_config) ]] && echo -e "$LEFT" >> /root/.sven/key_config
RIGHT="[114:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Right')
command=/root/Startup/rotate right
comment=Rotate Right\n"
[[ -z $(grep '114:64' /root/.sven/key_config) ]] && echo -e "$RIGHT" >> /root/.sven/key_config
INVERTED="[111:64]
type=cmd
enable=1
description=$(gettext 'Rotate Inverted')
command=/root/Startup/rotate inverted
comment=Rotate Inverted\n"
[[ -z $(grep '1116:4' /root/.sven/key_config) ]] && echo -e "$INVERTED" >> /root/.sven/key_config
NORMAL="[116:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen normal')
command=/root/Startup/rotate normal
comment=Rotate Screen Normal\n"
[[ -z $(grep '116:64' /root/.sven/key_config) ]] && echo -e "$NORMAL" >> /root/.sven/key_config
LH="[113:4]
type=cmd
enable=1
description=$(gettext 'Left Half of Screen')
command=/root/Startup/rotate LH
comment=Move Window to Left\n"
[[ -z $(grep '113:4' /root/.sven/key_config) ]] && echo -e "$LH" >> /root/.sven/key_config
RH="[114:4]
type=cmd
enable=1
description=$(gettext 'Right Half of Screem')
command=/root/Startup/rotate RH
comment=Move Window To Right\n"
[[ -z $(grep '114:4' /root/.sven/key_config) ]] && echo -e "$RH" >> /root/.sven/key_config
TH="[111:4]
type=cmd
enable=1
description=$(gettext 'Top Half of Screen')
command=/root/Startup/rotate TH
comment=Move to Top Half\n"
[[ -z $(grep '111:4' /root/.sven/key_config) ]] && echo -e "$TH" >> /root/.sven/key_config
BH="[116:4]
type=cmd
enable=1
description=$(gettext 'Bottom Half of Screen')
command=/root/Startup/rotate BH
comment=Move Window To Bottom\n"
[[ -z $(grep '116:4' /root/.sven/key_config) ]] && echo -e "$BH" >> /root/.sven/key_config
RHU="[111:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Top')
command=/root/Startup/rotate RHU
comment=\n"
[[ -z $(grep '111:8' /root/.sven/key_config) ]] && echo -e "$RHU" >> /root/.sven/key_config
RHD="[114:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Down')
command=/root/Startup/rotate RHD
comment=\n"
[[ -z $(grep '114:8' /root/.sven/key_config) ]] && echo -e "$RHD" >> /root/.sven/key_config
LHU="[113:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Top')
command=/root/Startup/rotate LHU
comment=\n"
[[ -z $(grep '113:8' /root/.sven/key_config) ]] && echo -e "$LHU" >> /root/.sven/key_config
LHD="[116:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Down')
command=/root/Startup/rotate LHD
comment=\n"
[[ -z $(grep '116:8' /root/.sven/key_config) ]] && echo -e "$LHD" >> /root/.sven/key_config
sven -k
sven &
};export -f add2sven
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
case $1 in
left) $1
;;
right) $1
;;
inverted) $1
;;
normal) $1
;;
BH) $1
;;
TH) $1
;;
RH) $1
;;
LH) $1
;;
LHD) $1
;;
LHU) $1
;;
RHD) $1
;;
RHU) $1
;;
sven) add2sven
;;
esac
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "icon:left.png" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "icon:right.png" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "icon:inverted.png" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "icon:normal.png" >>/tmp/RPIPE
}; export -f normal
function driveumnt {
umount /dev/"$1" /mnt/"$1"
#[ $? -eq 0 ] &&
printf "%s" "icon:/usr/share/pixmaps/driveOFF.png" >>/tmp/"$2"
};export -f driveumnt
function drivemnt {
mount /dev/"$1" /mnt/"$1"
#[ $? -eq 0 ] &&
printf "%s" "icon:/usr/share/pixmaps/driveON.png" >> /tmp/"$2"
};export -f drivemnt
function DrivIcons {
for i in $(ls /tmp/udev-fatdog-drive-icon/devices/*)
do
source "$i"
if [ ! -p /tmp/$DRIVENAME ]; then
sleep 0.5
mkfifo -m755 /tmp/$DRIVENAME
exec 4<> /tmp/$DRIVENAME
sleep 0.5
yad --notification --listen --text="$(gettext "$SUMMARY $DRIVENAME")" --tray-icon="/usr/share/pixmaps/driveON.png" --command="bash -c \"rox /mnt/$DRIVENAME \"" --menu="$(gettext "mount $DRIVENAME")!bash -c \"drivemnt $DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext "UnMount $DRIVENAME")!bash -c \"driveumnt $DRIVENAME \"!/usr/share/pixmaps/driveOFF.png|Close!quit!gtk-cancel" <& 4 &
sleep 0.5
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/"$DRIVENAME"
fi
done
icewm --replace
};export -f DrivIcons
function on_exit (){
rm -f /tmp/RPIPE
for i in $(ls /tmp/udev-fatdog-drive-icon/devices/*)
do
source $i
rm -f /tmp/$(basename $i)
done
}
export -f on_exit
trap 'on_exit' EXIT
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export HANDEL=$(echo RANDOM)
mkfifo -m755 /tmp/$HANDEL
exec 3<> /tmp/$HANDEL
function maingui (){
export WINDOWTITLE="$(gettext 'Mounter_Rotator')"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="$(gettext 'Mount'):FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="$(gettext 'Partition'):CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="$(gettext 'Mount Dir'):CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="$(gettext 'un-Mount'):FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="$(gettext 'Xinput Events'):TXT" "`xinput`" \
--field="$(gettext 'touchpad event id='):NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="$(gettext 'Touchscreen event id='):NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="$(gettext 'Rotate left'):FBTN" "bash -c \"left \"" \
--field="$(gettext 'Rotate right'):FBTN" "bash -c \"right \"" \
--field="$(gettext 'Rotate normal'):FBTN" "bash -c \"normal \"" \
--field="$(gettext 'Rotate inverted'):FBTN" "bash -c \"inverted \"" \
--field="$(gettext 'Store Events'):FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--field="$(gettext 'Create Drive Icons'):FBTN" "bash -c \"DrivIcons "%2" \"" \
--no-buttons \
--title="$(gettext "$WINDOWTITLE")" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
yad --notification --listen --text="$(gettext 'Click then position cursor to get right click menu')" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c 'sleep 4; xdotool click 3'" --menu="$(gettext 'Screen Rotation Win-Key + arrows')|$(gettext 'Window Placement Alt/Ctrl + arrows')|$(gettext 'Rotate Left')!bash -c left!/usr/share/pixmaps/left.png|$(gettext 'Rotate right')!bash -c right!/usr/share/pixmaps/right.png|$(gettext 'Rotate Inverted')!bash -c inverted!/usr/share/pixmaps/inverted.png|$(gettext 'Rotate Normal')!bash -c normal!/usr/share/pixmaps/normal.png|$(gettext 'GUI')!bash -c maingui!gtk-open|Write key-combos to sven!bash -c '/root/Startup/rotate sven'!gtk-save|$(gettext 'Close')!quit!gtk-cancel" <& 3 &
echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/$HANDEL
Re: Mounter_Rotator
Posted: Fri Jun 02, 2023 10:53 am
by geo_c
stemsee wrote: ↑Fri Jun 02, 2023 10:01 am
I have a mouse from the get go. I'm using lxqt-panel for my initial interface. I then open a terminal to fire up icewm, which seems to have similar functionality to your spectrwm.
I was a little unclear about how I said that. I do have a mouse when I boot, it's just that without the pinboard activated there is nothing to use it with until I open a program and get a window.
I don't think I'll be able to use wmctrl in spectrwm, but I'm not sure about that. I'll have to experiment with it.
It doesn't have a "tray," instead it has a "status bar" which displays information, and a launch menu which isn't mouse driven.
I can activate the Rox pinboard by uncommenting a single line in the spectrwm.conf file. I have the pinboard configured with my frequently used launchers.
Re: Mounter_Rotator
Posted: Sun Jun 04, 2023 7:26 pm
by stemsee
I feel my desktop has now been unleashed. No pinboard lets me do so much more. Vlc now plays video as wallpaper ... it probably always did but was behind the pinboard and I didn't know how to view it. Now I know. I will add options to rotator to remove pinboard when needed with one click.
Re: Mounter_Rotator
Posted: Tue Jun 06, 2023 7:51 am
by stemsee
Update! Drive mount and unmount with icons from tray. (fatdog only atm) Arbitrarily limited to 12 devices.
Code: Select all
#!/bin/sh
# Copyright (C) 2014 stemsee
# gpl v3 license applies for personal use
#[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
function BH
{
YY=$(((YY / 2) - 33))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function TH
{
YY=$((YY / 2))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function RH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function LHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LHD
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function RHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function RHD
{
XX=$((XX / 2))
YY=$((YY / 2 ))
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
}
function add2sven
{
LEFT="[113:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Left')
command=/root/Startup/rotate left
comment=Rotate Left\n"
[[ -z $(grep '113:64' /root/.sven/key_config) ]] && echo -e "$LEFT" >> /root/.sven/key_config
RIGHT="[114:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Right')
command=/root/Startup/rotate right
comment=Rotate Right\n"
[[ -z $(grep '114:64' /root/.sven/key_config) ]] && echo -e "$RIGHT" >> /root/.sven/key_config
INVERTED="[111:64]
type=cmd
enable=1
description=$(gettext 'Rotate Inverted')
command=/root/Startup/rotate inverted
comment=Rotate Inverted\n"
[[ -z $(grep '1116:4' /root/.sven/key_config) ]] && echo -e "$INVERTED" >> /root/.sven/key_config
NORMAL="[116:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen normal')
command=/root/Startup/rotate normal
comment=Rotate Screen Normal\n"
[[ -z $(grep '116:64' /root/.sven/key_config) ]] && echo -e "$NORMAL" >> /root/.sven/key_config
LH="[113:4]
type=cmd
enable=1
description=$(gettext 'Left Half of Screen')
command=/root/Startup/rotate LH
comment=Move Window to Left\n"
[[ -z $(grep '113:4' /root/.sven/key_config) ]] && echo -e "$LH" >> /root/.sven/key_config
RH="[114:4]
type=cmd
enable=1
description=$(gettext 'Right Half of Screem')
command=/root/Startup/rotate RH
comment=Move Window To Right\n"
[[ -z $(grep '114:4' /root/.sven/key_config) ]] && echo -e "$RH" >> /root/.sven/key_config
TH="[111:4]
type=cmd
enable=1
description=$(gettext 'Top Half of Screen')
command=/root/Startup/rotate TH
comment=Move to Top Half\n"
[[ -z $(grep '111:4' /root/.sven/key_config) ]] && echo -e "$TH" >> /root/.sven/key_config
BH="[116:4]
type=cmd
enable=1
description=$(gettext 'Bottom Half of Screen')
command=/root/Startup/rotate BH
comment=Move Window To Bottom\n"
[[ -z $(grep '116:4' /root/.sven/key_config) ]] && echo -e "$BH" >> /root/.sven/key_config
RHU="[111:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Top')
command=/root/Startup/rotate RHU
comment=\n"
[[ -z $(grep '111:8' /root/.sven/key_config) ]] && echo -e "$RHU" >> /root/.sven/key_config
RHD="[114:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Down')
command=/root/Startup/rotate RHD
comment=\n"
[[ -z $(grep '114:8' /root/.sven/key_config) ]] && echo -e "$RHD" >> /root/.sven/key_config
LHU="[113:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Top')
command=/root/Startup/rotate LHU
comment=\n"
[[ -z $(grep '113:8' /root/.sven/key_config) ]] && echo -e "$LHU" >> /root/.sven/key_config
LHD="[116:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Down')
command=/root/Startup/rotate LHD
comment=\n"
[[ -z $(grep '116:8' /root/.sven/key_config) ]] && echo -e "$LHD" >> /root/.sven/key_config
sven -k
sven &
};export -f add2sven
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
case $1 in
left) $1
;;
right) $1
;;
inverted) $1
;;
normal) $1
;;
BH) $1
;;
TH) $1
;;
RH) $1
;;
LH) $1
;;
LHD) $1
;;
LHU) $1
;;
RHD) $1
;;
RHU) $1
;;
sven) add2sven
;;
esac
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "icon:left.png" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "icon:right.png" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=$(echo "$events" | cut -f2 -d' ')
pad=$(echo "$events" | cut -f1 -d' ')
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "icon:inverted.png" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "icon:normal.png" >>/tmp/RPIPE
}; export -f normal
function driveumnt {
umount /dev/"$1" /mnt/"$1"
echo "icon:/usr/share/pixmaps/driveOFF.png" >>/tmp/DRIVES
};export -f driveumnt
function drivemnt {
mount /dev/"$1" /mnt/"$1"
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
};export -f drivemnt
function DrivIcons {
mkfifo -m755 /tmp/DRIVES
exec 8<> /tmp/DRIVES
cnt=1
for i in $(ls /tmp/udev-fatdog-drive-icon/devices/*)
do
source "$i"
export MENU$cnt="$(gettext "mount $DRIVENAME")!bash -c \"drivemnt $DRIVENAME;rox /mnt/$DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext "UnMount $DRIVENAME")!bash -c \"driveumnt $DRIVENAME \"!/usr/share/pixmaps/driveOFF.png||"
export cnt=$((cnt + 1))
done
yad --notification --listen --text="$(gettext "$SUMMARY $DRIVENAME")" --tray-icon="/usr/share/pixmaps/driveON.png" --command="bash -c \"rox /mnt/$DRIVENAME \"" --menu="$(gettext 'Drive Mounting')|||$MENU12$MENU11$MENU10$MENU9$MENU8$MENU7$MENU6$MENU5$MENU4$MENU3$MENU2$MENU1|Close!quit!gtk-cancel" <& 8 &
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
}; export -f DrivIcons
function on_exit (){
rm -f /tmp/RPIPE
for i in $(ls /tmp/udev-fatdog-drive-icon/devices/*)
do
source $i
rm -f /tmp/$(basename $i)
done
}
export -f on_exit
trap 'on_exit' EXIT
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export HANDEL=$(echo RANDOM)
mkfifo -m755 /tmp/$HANDEL
exec 1<> /tmp/$HANDEL
function maingui (){
export WINDOWTITLE="$(gettext 'Mounter_Rotator')"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="$(gettext 'Mount'):FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="$(gettext 'Partition'):CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="$(gettext 'Mount Dir'):CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="$(gettext 'un-Mount'):FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="$(gettext 'Xinput Events'):TXT" "`xinput`" \
--field="$(gettext 'touchpad event id='):NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="$(gettext 'Touchscreen event id='):NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="$(gettext 'Rotate left'):FBTN" "bash -c \"left \"" \
--field="$(gettext 'Rotate right'):FBTN" "bash -c \"right \"" \
--field="$(gettext 'Rotate normal'):FBTN" "bash -c \"normal \"" \
--field="$(gettext 'Rotate inverted'):FBTN" "bash -c \"inverted \"" \
--field="$(gettext 'Store Events'):FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--field="$(gettext 'Create Drive Icons'):FBTN" "bash -c 'DrivIcons'" \
--no-buttons \
--title="$(gettext "$WINDOWTITLE")" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
yad --notification --listen --text="$(gettext 'Click then position cursor to get right click menu')" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c 'sleep 4; xdotool click 3'" --menu="$(gettext 'Harddrives')!bash -c DrivIcons!/usr/share/pixmaps/driveON.png|$(gettext 'Screen Rotation Win-Key + arrows')|$(gettext 'Window Placement Alt/Ctrl + arrows')|$(gettext 'Rotate Left')!bash -c left!/usr/share/pixmaps/left.png|$(gettext 'Rotate right')!bash -c right!/usr/share/pixmaps/right.png|$(gettext 'Rotate Inverted')!bash -c inverted!/usr/share/pixmaps/inverted.png|$(gettext 'Rotate Normal')!bash -c normal!/usr/share/pixmaps/normal.png|$(gettext 'GUI')!bash -c maingui!gtk-open|Write key-combos to sven!bash -c '/root/Startup/rotate sven'!gtk-save|$(gettext 'Close')!quit!gtk-cancel" <& 1 &
echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/$HANDEL
- rotatedrives.png (55.71 KiB) Viewed 1629 times
Re: Mounter_Rotator
Posted: Tue Jun 06, 2023 8:15 pm
by Dry Falls
Works in Lighthouse too. Only tried with mate panel so far -no fuss- so it should be ok with others too. Thanks @stemsee.
Re: Mounter_Rotator
Posted: Wed Jun 07, 2023 9:49 am
by stemsee
hi @ Dry Falls
Thanks for feedback!
Everything works? Drives get listed according to what is attached to your system??
I'm going to finesse it so that drive icons reflect mounted or unmounted status, and show only the relevant icon.
Re: Mounter_Rotator
Posted: Wed Jun 07, 2023 1:52 pm
by stemsee
This should work for all distros, and it handles swap partitions too.
- swaprotate.png (76.8 KiB) Viewed 1570 times
Code: Select all
#!/bin/sh
# Copyright (C) 2014 stemsee
# gpl v3 license applies for personal use
#[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
function BH
{
YY=$(((YY / 2) - 33))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function TH
{
YY=$((YY / 2))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function RH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function LHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LHD
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function RHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function RHD
{
XX=$((XX / 2))
YY=$((YY / 2 ))
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
}
function add2sven
{
LEFT="[113:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Left')
command=/root/Startup/rotate left
comment=Rotate Left\n"
[[ -z $(grep '113:64' /root/.sven/key_config) ]] && echo -e "$LEFT" >> /root/.sven/key_config
RIGHT="[114:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Right')
command=/root/Startup/rotate right
comment=Rotate Right\n"
[[ -z $(grep '114:64' /root/.sven/key_config) ]] && echo -e "$RIGHT" >> /root/.sven/key_config
INVERTED="[111:64]
type=cmd
enable=1
description=$(gettext 'Rotate Inverted')
command=/root/Startup/rotate inverted
comment=Rotate Inverted\n"
[[ -z $(grep '1116:4' /root/.sven/key_config) ]] && echo -e "$INVERTED" >> /root/.sven/key_config
NORMAL="[116:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen normal')
command=/root/Startup/rotate normal
comment=Rotate Screen Normal\n"
[[ -z $(grep '116:64' /root/.sven/key_config) ]] && echo -e "$NORMAL" >> /root/.sven/key_config
LH="[113:4]
type=cmd
enable=1
description=$(gettext 'Left Half of Screen')
command=/root/Startup/rotate LH
comment=Move Window to Left\n"
[[ -z $(grep '113:4' /root/.sven/key_config) ]] && echo -e "$LH" >> /root/.sven/key_config
RH="[114:4]
type=cmd
enable=1
description=$(gettext 'Right Half of Screem')
command=/root/Startup/rotate RH
comment=Move Window To Right\n"
[[ -z $(grep '114:4' /root/.sven/key_config) ]] && echo -e "$RH" >> /root/.sven/key_config
TH="[111:4]
type=cmd
enable=1
description=$(gettext 'Top Half of Screen')
command=/root/Startup/rotate TH
comment=Move to Top Half\n"
[[ -z $(grep '111:4' /root/.sven/key_config) ]] && echo -e "$TH" >> /root/.sven/key_config
BH="[116:4]
type=cmd
enable=1
description=$(gettext 'Bottom Half of Screen')
command=/root/Startup/rotate BH
comment=Move Window To Bottom\n"
[[ -z $(grep '116:4' /root/.sven/key_config) ]] && echo -e "$BH" >> /root/.sven/key_config
RHU="[111:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Top')
command=/root/Startup/rotate RHU
comment=\n"
[[ -z $(grep '111:8' /root/.sven/key_config) ]] && echo -e "$RHU" >> /root/.sven/key_config
RHD="[114:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Down')
command=/root/Startup/rotate RHD
comment=\n"
[[ -z $(grep '114:8' /root/.sven/key_config) ]] && echo -e "$RHD" >> /root/.sven/key_config
LHU="[113:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Top')
command=/root/Startup/rotate LHU
comment=\n"
[[ -z $(grep '113:8' /root/.sven/key_config) ]] && echo -e "$LHU" >> /root/.sven/key_config
LHD="[116:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Down')
command=/root/Startup/rotate LHD
comment=\n"
[[ -z $(grep '116:8' /root/.sven/key_config) ]] && echo -e "$LHD" >> /root/.sven/key_config
sven -k
sven &
};export -f add2sven
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
case $1 in
left) $1
;;
right) $1
;;
inverted) $1
;;
normal) $1
;;
BH) $1
;;
TH) $1
;;
RH) $1
;;
LH) $1
;;
LHD) $1
;;
LHU) $1
;;
RHD) $1
;;
RHU) $1
;;
sven) add2sven
;;
esac
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "icon:left.png" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "icon:right.png" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=$(echo "$events" | cut -f2 -d' ')
pad=$(echo "$events" | cut -f1 -d' ')
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "icon:inverted.png" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "icon:normal.png" >>/tmp/RPIPE
}; export -f normal
function driveumnt {
umount /dev/"$1" /mnt/"$1"
echo "icon:/usr/share/pixmaps/driveOFF.png" >>/tmp/DRIVES
};export -f driveumnt
function drivemnt {
mount /dev/"$1" /mnt/"$1"
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
};export -f drivemnt
function DrivIcons {
mkfifo -m755 /tmp/DRIVES
exec 8<> /tmp/DRIVES
cnt=1
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
INFO=$(lsblk "$i" | tail -n1)
SWAP=$(cat /proc/swaps | tail -n+1 | cut -f1 -d' ' | grep $i)
[ "$SWAP" ] && i="SWAP"
case "$i" in
'/dev/sd'*|'/dev/mmcblk'*) DRIVENAME=$(basename $i)
export MENU$cnt="$(gettext 'mount') $INFO!bash -c \"drivemnt $DRIVENAME;rox /mnt/$DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext 'UnMount') $DRIVENAME!bash -c \"driveumnt $DRIVENAME \"!/usr/share/pixmaps/driveOFF.png||";;
SWAP) DRIVENAME=$(echo $INFO | cut -f1 -d' ')
export MENU$cnt="$(gettext 'Swap On') $INFO!bash -c \"swapon /dev/$DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext 'Swap Off') $DRIVENAME!bash -c \"swapoff /dev/$DRIVENAME \"!/usr/share/pixmaps/driveOFF.png||"
;;
esac
export cnt=$((cnt + 1))
unset SWAP
done
yad --notification --listen --text="$(gettext "Storage Devices")" --tray-icon="/usr/share/pixmaps/driveON.png" --command="bash -c \"rox /mnt/ \"" --menu="$(gettext 'Drive Mounting')|||$MENU12$MENU11$MENU10$MENU9$MENU8$MENU7$MENU6$MENU5$MENU4$MENU3$MENU2$MENU1|Close!quit!gtk-cancel" <& 8 &
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
}; export -f DrivIcons
function on_exit (){
rm -f /tmp/RPIPE
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
rm -f /tmp/$(basename $i)
done
}
export -f on_exit
trap 'on_exit' EXIT
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export HANDEL="$RANDOM"
mkfifo -m755 /tmp/$HANDEL
exec 1<> /tmp/$HANDEL
function maingui (){
export WINDOWTITLE="$(gettext 'Mounter_Rotator')"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="$(gettext 'Mount'):FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="$(gettext 'Partition'):CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="$(gettext 'Mount Dir'):CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="$(gettext 'un-Mount'):FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="$(gettext 'Xinput Events'):TXT" "`xinput`" \
--field="$(gettext 'touchpad event id='):NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="$(gettext 'Touchscreen event id='):NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="$(gettext 'Rotate left'):FBTN" "bash -c \"left \"" \
--field="$(gettext 'Rotate right'):FBTN" "bash -c \"right \"" \
--field="$(gettext 'Rotate normal'):FBTN" "bash -c \"normal \"" \
--field="$(gettext 'Rotate inverted'):FBTN" "bash -c \"inverted \"" \
--field="$(gettext 'Store Events'):FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--field="$(gettext 'Create Drive Icons'):FBTN" "bash -c 'DrivIcons'" \
--no-buttons \
--title="$(gettext "$WINDOWTITLE")" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
yad --notification --listen --text="$(gettext 'Click then position cursor to get right click menu')" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c 'sleep 4; xdotool click 3'" --menu="$(gettext 'Storage Devices')!bash -c DrivIcons!/usr/share/pixmaps/driveON.png|$(gettext 'Screen Rotation Win-Key + arrows')|$(gettext 'Window Placement Alt/Ctrl + arrows')|$(gettext 'Rotate Left')!bash -c left!/usr/share/pixmaps/left.png|$(gettext 'Rotate right')!bash -c right!/usr/share/pixmaps/right.png|$(gettext 'Rotate Inverted')!bash -c inverted!/usr/share/pixmaps/inverted.png|$(gettext 'Rotate Normal')!bash -c normal!/usr/share/pixmaps/normal.png|$(gettext 'GUI')!bash -c maingui!gtk-open|Write key-combos to sven!bash -c '/root/Startup/rotate sven'!gtk-save|$(gettext 'Close')!quit!gtk-cancel" <& 1 &
echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/$HANDEL
Re: Mounter_Rotator
Posted: Mon Jun 26, 2023 8:49 pm
by stemsee
This takes language as first argument in case transtext-gettext script is installed:
example
rotate de
Code: Select all
#!/bin/ash
# Copyright (C) 2014 stemsee
# gpl v3 license applies for personal use
#[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\""
export TEXTDOMAIN="rotate"
export lng="$1"
res=`xwininfo -root | grep -e 'Height' -e 'Width' | awk '{print $2}'`
XX=`echo $res | awk '{print $1}'`
YY=`echo $res | awk '{print $2}'`
function BH
{
YY=$(((YY / 2) - 33))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function TH
{
YY=$((YY / 2))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function RH
{
XX=$((XX / 2))
YY=$((YY - 56))
wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function LHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,0,$XX,$YY
}
function LHD
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,0,$YY,$XX,$YY
}
function RHU
{
XX=$((XX / 2))
YY=$((YY / 2))
wmctrl -r :ACTIVE: -e 0,$XX,0,$XX,$YY
}
function RHD
{
XX=$((XX / 2))
YY=$((YY / 2 ))
wmctrl -r :ACTIVE: -e 0,$XX,$YY,$XX,$YY
}
function add2sven
{
LEFT="[113:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Left')
command=/root/Startup/rotate left
comment=Rotate Left\n"
[[ -z $(grep '113:64' /root/.sven/key_config) ]] && echo -e "$LEFT" >> /root/.sven/key_config
RIGHT="[114:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen Right')
command=/root/Startup/rotate right
comment=Rotate Right\n"
[[ -z $(grep '114:64' /root/.sven/key_config) ]] && echo -e "$RIGHT" >> /root/.sven/key_config
INVERTED="[111:64]
type=cmd
enable=1
description=$(gettext 'Rotate Inverted')
command=/root/Startup/rotate inverted
comment=Rotate Inverted\n"
[[ -z $(grep '1116:4' /root/.sven/key_config) ]] && echo -e "$INVERTED" >> /root/.sven/key_config
NORMAL="[116:64]
type=cmd
enable=1
description=$(gettext 'Rotate Screen normal')
command=/root/Startup/rotate normal
comment=Rotate Screen Normal\n"
[[ -z $(grep '116:64' /root/.sven/key_config) ]] && echo -e "$NORMAL" >> /root/.sven/key_config
LH="[113:4]
type=cmd
enable=1
description=$(gettext 'Left Half of Screen')
command=/root/Startup/rotate LH
comment=Move Window to Left\n"
[[ -z $(grep '113:4' /root/.sven/key_config) ]] && echo -e "$LH" >> /root/.sven/key_config
RH="[114:4]
type=cmd
enable=1
description=$(gettext 'Right Half of Screem')
command=/root/Startup/rotate RH
comment=Move Window To Right\n"
[[ -z $(grep '114:4' /root/.sven/key_config) ]] && echo -e "$RH" >> /root/.sven/key_config
TH="[111:4]
type=cmd
enable=1
description=$(gettext 'Top Half of Screen')
command=/root/Startup/rotate TH
comment=Move to Top Half\n"
[[ -z $(grep '111:4' /root/.sven/key_config) ]] && echo -e "$TH" >> /root/.sven/key_config
BH="[116:4]
type=cmd
enable=1
description=$(gettext 'Bottom Half of Screen')
command=/root/Startup/rotate BH
comment=Move Window To Bottom\n"
[[ -z $(grep '116:4' /root/.sven/key_config) ]] && echo -e "$BH" >> /root/.sven/key_config
RHU="[111:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Top')
command=/root/Startup/rotate RHU
comment=\n"
[[ -z $(grep '111:8' /root/.sven/key_config) ]] && echo -e "$RHU" >> /root/.sven/key_config
RHD="[114:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Right Down')
command=/root/Startup/rotate RHD
comment=\n"
[[ -z $(grep '114:8' /root/.sven/key_config) ]] && echo -e "$RHD" >> /root/.sven/key_config
LHU="[113:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Top')
command=/root/Startup/rotate LHU
comment=\n"
[[ -z $(grep '113:8' /root/.sven/key_config) ]] && echo -e "$LHU" >> /root/.sven/key_config
LHD="[116:8]
type=cmd
enable=1
description=$(gettext 'Move Window to Left Down')
command=/root/Startup/rotate LHD
comment=\n"
[[ -z $(grep '116:8' /root/.sven/key_config) ]] && echo -e "$LHD" >> /root/.sven/key_config
sven -k
sven &
};export -f add2sven
export TRANSFORM='Coordinate Transformation Matrix'
export OUTPUT_CHARSET=UTF-8
case $1 in
left) $1
;;
right) $1
;;
inverted) $1
;;
normal) $1
;;
BH) $1
;;
TH) $1
;;
RH) $1
;;
LH) $1
;;
LHD) $1
;;
LHU) $1
;;
RHD) $1
;;
RHU) $1
;;
sven) add2sven
;;
esac
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
function left (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate left
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
echo "left" >/etc/rotate
echo "icon:left.png" >>/tmp/RPIPE
}; export -f left
function right (){
events=$(cat /etc/rotate_events)
export touch=`echo "$events" | cut -f2 -d' '`
export pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate right
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
xinput set-prop "$touch" "Evdev Axes Swap" 1
xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
echo "right" >/etc/rotate
echo "icon:right.png" >>/tmp/RPIPE
}; export -f right
function inverted (){
events=$(cat /etc/rotate_events)
touch=$(echo "$events" | cut -f2 -d' ')
pad=$(echo "$events" | cut -f1 -d' ')
xrandr --output "$connected" --rotate inverted
xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
echo "inverted" >/etc/rotate
echo "icon:inverted.png" >>/tmp/RPIPE
}; export -f inverted
function normal (){
events=$(cat /etc/rotate_events)
touch=`echo "$events" | cut -f2 -d' '`
pad=`echo "$events" | cut -f1 -d' '`
xrandr --output "$connected" --rotate normal
xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
xinput set-prop "$touch" "Evdev Axes Swap" 0
xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
echo "normal" >/etc/rotate
echo "icon:normal.png" >>/tmp/RPIPE
}; export -f normal
function rotate_flipx {
xrandr -x
};export -f rotate_flipx
function rotate_flipy {
xrandr -y
};export -f rotate_flipy
function rotate_flip_normal {
xrandr -o normal
};export rotate_flip_normal
function driveumnt {
umount /dev/"$1" /mnt/"$1"
DrivIcons
echo "icon:/usr/share/pixmaps/driveOFF.png" >>/tmp/DRIVES
};export -f driveumnt
function drivemnt {
mount /dev/"$1" /mnt/"$1"
DrivIcons
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
};export -f drivemnt
function DrivIcons {
mkfifo -m755 /tmp/DRIVES
exec 8<> /tmp/DRIVES
cnt=1
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
INFO=$(lsblk "$i" | tail -n1)
SWAP=$(cat /proc/swaps | tail -n+1 | cut -f1 -d' ' | grep $i)
[ "$SWAP" ] && i="SWAP"
case "$i" in
'/dev/sd'*|'/dev/mmcblk'*) DRIVENAME=$(basename $i)
export MENU$cnt="$(gettext 'mount') $INFO!bash -c \"drivemnt $DRIVENAME;rox /mnt/$DRIVENAME \"!/usr/share/pixmaps/driveON.png|$(gettext 'UnMount') $DRIVENAME!bash -c \"driveumnt $DRIVENAME \"!/usr/share/pixmaps/driveOFF.png||";;
SWAP) DRIVENAME=$(echo $INFO | cut -f1 -d' ')
export MENU$cnt="$(gettext 'Swap On') $INFO!bash -c \"swapon /dev/$DRIVENAME;DivvIcons \"!/usr/share/pixmaps/driveON.png|$(gettext 'Swap Off') $DRIVENAME!bash -c \"swapoff /dev/$DRIVENAME;DrivIcons \"!/usr/share/pixmaps/driveOFF.png||"
;;
esac
export cnt=$((cnt + 1))
unset SWAP
done
yad --notification --listen --text="$(gettext "Storage Devices")" --tray-icon="/usr/share/pixmaps/driveON.png" --command="bash -c \"rox /mnt/ \"" --menu="$(gettext 'Drive Mounting')|||$MENU12$MENU11$MENU10$MENU9$MENU8$MENU7$MENU6$MENU5$MENU4$MENU3$MENU2$MENU1|Close!quit!gtk-cancel" <& 8 &
echo "icon:/usr/share/pixmaps/driveON.png" >> /tmp/DRIVES
}; export -f DrivIcons
function on_exit (){
rm -f /tmp/RPIPE
for i in $(fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' ' ')
do
rm -f /tmp/$(basename $i)
done
}
export -f on_exit
trap 'on_exit' EXIT
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export HANDEL="$RANDOM"
mkfifo -m755 /tmp/$HANDEL
exec 1<> /tmp/$HANDEL
function maingui (){
export WINDOWTITLE="$(gettext 'Mounter_Rotator')"
sayonara 8 &
yad --center \
--form --item-separator='#' \
--field="$(gettext 'Mount'):FBTN" "bash -c \"mkdir -p "%3"; mount "%2" "%3" \"" \
--field="$(gettext 'Partition'):CBE" "`fdisk -l | grep dev | grep -v Disk | awk '{print $1}' | tr '\n' '#'``blkid -o device | tr '\n' '#'`" \
--field="$(gettext 'Mount Dir'):CBE" `ls /mnt | sed 's|^|/mnt/|g' | tr '\n' '#'``ls /media | sed 's|^|/media/|g' | tr '\n' '#'``ls /aufs | sed 's|^|/aufs/|g' | tr '\n' '#'` \
--field="$(gettext 'un-Mount'):FBTN" "bash -c \"umount -f -A "%2"; umount -f -A "%3" \"" \
--field="$(gettext 'Xinput Events'):TXT" "`xinput`" \
--field="$(gettext 'touchpad event id='):NUM" "`cat /etc/rotate_events | cut -f1 -d' '`" \
--field="$(gettext 'Touchscreen event id='):NUM" "`cat /etc/rotate_events | cut -f2 -d' '`" \
--field="$(gettext 'Store Events'):FBTN" "bash -c \"echo "%6" "%7" >/etc/rotate_events \"" \
--field="$(gettext 'Rotate left'):FBTN" "bash -c \"left \"" \
--field="$(gettext 'Rotate right'):FBTN" "bash -c \"right \"" \
--field="$(gettext 'Rotate normal'):FBTN" "bash -c \"normal \"" \
--field="$(gettext 'Rotate inverted'):FBTN" "bash -c \"inverted \"" \
--field="$(gettext 'Mirror X axis'):FBTN" "bash -c 'rotate_flipx'" \
--field="$(gettext 'Mirror Y axis'):FBTN" "bash -c 'rotate_flipy'" \
--field="$(gettext 'Create Drive Icons'):FBTN" "bash -c 'DrivIcons'" \
--no-buttons \
--title="$(gettext "$WINDOWTITLE")" --window-icon="gtk-refresh" \
--geometry="$(cat /root/.config/geometry/$WINDOWTITLE)" &
}; export -f maingui
yad --notification --listen --text="$(gettext 'Click then position cursor to get right click menu')" --tray-icon="/usr/share/pixmaps/normal.png" --command="bash -c 'sleep 4; xdotool click 3'" --menu="$(gettext 'Storage Devices')!bash -c DrivIcons!/usr/share/pixmaps/driveON.png|$(gettext 'Screen Rotation Win-Key + arrows')|$(gettext 'Window Placement Alt/Ctrl + arrows')|$(gettext 'Rotate Left')!bash -c left!/usr/share/pixmaps/left.png|$(gettext 'Rotate right')!bash -c right!/usr/share/pixmaps/right.png|$(gettext 'Rotate Inverted')!bash -c inverted!/usr/share/pixmaps/inverted.png|$(gettext 'Rotate Normal')!bash -c normal!/usr/share/pixmaps/normal.png|$(gettext 'Mirror X axis')!bash -c 'rotate_flipx'!/usr/share/pixmaps/flipx.png|$(gettext 'Mirror Y axis')!bash -c 'rotate_flipy'!/usr/share/pixmaps/flipy.png|$(gettext 'GUI')!bash -c maingui!gtk-open|Write key-combos to sven!bash -c '/root/Startup/rotate sven'!gtk-save|$(gettext 'Close')!quit!gtk-cancel" <& 1 &
echo "icon:/usr/share/pixmaps/normal.png" >> /tmp/$HANDEL
Re: Mounter_Rotator
Posted: Fri Jul 14, 2023 8:36 am
by stemsee