I am using F96-CE3 iso, I usually work with 6 virtual screens.
If I am on a browser in screen 1 and I have geany opened in screen 5, my jwmrc-personal file has been setup so I have to use the keyboard Mod4+5 to work on geany that is alreay launched. How can I edit the file to move via Ctrl+Shift+Right/Left arrow key to go directly to an occupied screen and skip the empty screens? So if screen 2,3,4 are empty, will go to geany screen.
keyboard shortcuts to skip empty virtual screen?(SOLVED)
Moderator: Forum moderators
- gychang
- Posts: 591
- Joined: Fri Aug 28, 2020 4:51 pm
- Location: San Diego, CA
- Has thanked: 206 times
- Been thanked: 64 times
keyboard shortcuts to skip empty virtual screen?(SOLVED)
- MochiMoppel
- Posts: 1233
- Joined: Mon Jun 15, 2020 6:25 am
- Location: Japan
- Has thanked: 21 times
- Been thanked: 437 times
Re: keyboard shortcuts to skip empty virtual screen?
Create a script with following code and make it executable:
Code: Select all
#!/bin/sh
## called without argument: switch to next non-empty desktop
## called with any argument: switch to previous non-empty desktop
[ $1 ] && REV=-r
CDT=$(xprop -root _NET_CURRENT_DESKTOP)
CDT=${CDT##* }
LST=$(wmctrl -l | awk -v cdt=$CDT '{print $2};END{print cdt}' | sort $REV -un)
NXT=$(echo "$LST" | sed -n "/^$CDT$/{n;p}")
wmctrl -s $NXT
Without any argument the script will jump to the next occupied desktop from left to right.
To move in the opposite direction the script needs to be called with an argument. Can be any string
In my test the script is called "next_dt" and the argument "reverse".
Add to your /root/.jwm/jwmrc-personal file, adjust the path, save the file and then run jwm -restart
Code: Select all
<Key key="Right" mask="CS">exec:/path/to/next_dt</Key>
<Key key="Left" mask="CS">exec:/path/to/next_dt reverse</Key>
- pp4mnklinux
- Posts: 1125
- Joined: Wed Aug 19, 2020 5:43 pm
- Location: Edinburgh
- Has thanked: 632 times
- Been thanked: 281 times
- Contact:
Other suggestion
Hello.-
You didn't mark as SOLVED your question, so I don't know if the proposed solution worked or not, just in case not, you can test this:
You must modify your jwmrc-personal file to move to an occupied screen and skip the empty screens, you can add the following lines to the <Key> section of the file:
Code: Select all
<Key mask="C|S">Right</Key>
<Action name="GoTo">
<NextOccupied/>
</Action>
<Key mask="C|S">Left</Key>
<Action name="GoTo">
<PrevOccupied/>
</Action>
These lines define key bindings for Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys to move to the next or previous occupied screen, respectively.
The <NextOccupied/> and <PrevOccupied/> tags in the <Action> section specify that the action should go to the next or previous occupied screen, respectively. This will skip any empty screens and go directly to the screen where an application is currently open.
Here's an example of how you can integrate these lines into your jwmrc-personal file:
Code: Select all
<JWM>
<Key mask="Mod4" key="5">
<Action name="GoTo">
<Desktop>5</Desktop>
</Action>
</Key>
<Key mask="C|S">Right</Key>
<Action name="GoTo">
<NextOccupied/>
</Action>
<Key mask="C|S">Left</Key>
<Action name="GoTo">
<PrevOccupied/>
</Action>
</JWM>
This example includes the lines for Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys as well as the original key binding for Mod4+5 to move to screen 5 where geany is open.
Save the modified jwmrc-personal file and restart JWM or reload the configuration file with jwm -reload to apply the changes. You should now be able to use Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys to move directly to an occupied screen and skip any empty screens.
If you want, you can test it and try.
Please, Mark your post as SOLVED if any solutions solve this.-
Have a nice day.
Learning EASY OS https://easyos.org/
DevuanPup XFCE_FUSILLI https://devuanpup.wordpress.com/
f96ce XFCE_FUSILLI https://puppyxfcefusilli.wordpress.com/
YouTube HOW_TO... https://bit.ly/f96ce_xfce_fusilli_HOWTO
- gychang
- Posts: 591
- Joined: Fri Aug 28, 2020 4:51 pm
- Location: San Diego, CA
- Has thanked: 206 times
- Been thanked: 64 times
Re: Other suggestion
pp4mnklinux wrote: ↑Sat Apr 01, 2023 8:04 amYou must modify your jwmrc-personal file to move to an occupied screen and skip the empty screens, you can add the following lines to the <Key> section of the file:
Code: Select all
<Key mask="C|S">Right</Key> <Action name="GoTo"> <NextOccupied/> </Action> <Key mask="C|S">Left</Key> <Action name="GoTo"> <PrevOccupied/> </Action>
These lines define key bindings for Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys to move to the next or previous occupied screen, respectively.
The <NextOccupied/> and <PrevOccupied/> tags in the <Action> section specify that the action should go to the next or previous occupied screen, respectively. This will skip any empty screens and go directly to the screen where an application is currently open.
I tried this and does not work for me, I tried CS instead of C|S and right instead of Right but still no joy. Will try this on a fresh install on this same ISO and report back. thanks
- Attachments
-
- Screenshot(1).png (42.26 KiB) Viewed 459 times
- gychang
- Posts: 591
- Joined: Fri Aug 28, 2020 4:51 pm
- Location: San Diego, CA
- Has thanked: 206 times
- Been thanked: 64 times
Re: Other suggestion
pp4mnklinux wrote: ↑Sat Apr 01, 2023 8:04 amYou must modify your jwmrc-personal file to move to an occupied screen and skip the empty screens, you can add the following lines to the <Key> section of the file:
Code: Select all
<Key mask="C|S">Right</Key> <Action name="GoTo"> <NextOccupied/> </Action> <Key mask="C|S">Left</Key> <Action name="GoTo"> <PrevOccupied/> </Action>
These lines define key bindings for Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys to move to the next or previous occupied screen, respectively.
Save the modified jwmrc-personal file and restart JWM or reload the configuration file with jwm -reload to apply the changes. You should now be able to use Ctrl+Shift+Right and Ctrl+Shift+Left arrow keys to move directly to an occupied screen and skip any empty screens.
I tried this on a fresh copy of F96-CE_3.iso added your lines to .jwmrc-personal followed by jwm -restart on terminal. Still no joy.
Code: Select all
<?xml version="1.0"?>
<!-- Personally configurable options for JWM: these override default settings and theme settings -->
<JWM>
<!-- Number of virtual desktops -->
<Desktops width="3" height="1"/>
<!-- Double click speed (in milliseconds) -->
<DoubleClickSpeed>400</DoubleClickSpeed>
<!-- Double click delta (in pixels) -->
<DoubleClickDelta>3</DoubleClickDelta>
<!-- The focus model (sloppy or click) -->
<FocusModel>click</FocusModel>
<!-- The snap mode (none, screen, or border) -->
<SnapMode distance="10">none</SnapMode>
<!-- The move mode (outline or opaque) -->
<MoveMode coordinates="off" delay="1000">opaque</MoveMode>
<!-- The resize mode (outline or opaque) -->
<ResizeMode coordinates="off">opaque</ResizeMode>
<!-- group options set for all windows -->
<Group>
<!-- disable flashing in tray for urgent windows -->
<Option>noturgent</Option>
<!-- placement for new window (default is cascaded) -->
<!-- <Option>tiled</Option> -->
<!-- auto-maximization when moving window to top/side of desktop -->
<!-- <Option>aerosnap</Option> -->
</Group>
<!-- Start Firefox centered or maximized, default is centered -->
<Group>
<Name>Navigator</Name>
<Name>Firefox</Name>
<Option>centered</Option>
</Group>
<!-- Key bindings -->
<Key key="Up">up</Key>
<Key key="Down">down</Key>
<Key key="Right">right</Key>
<Key key="Left">left</Key>
<Key key="h">left</Key>
<Key key="j">down</Key>
<Key key="k">up</Key>
<Key key="l">right</Key>
<Key key="Return">select</Key>
<Key key="Escape">escape</Key>
<Key key="F12">root:3</Key>
<Key mask="CA" key="Right">rdesktop</Key>
<Key mask="CA" key="Left">ldesktop</Key>
<Key mask="CA" key="Up">udesktop</Key>
<Key mask="CA" key="Down">ddesktop</Key>
<Key mask="A" key="Tab">nextstacked</Key>
<Key mask="AS" key="Tab">prevstacked</Key>
<Key mask="A" key="F4">close</Key>
<Key mask="A" key="F10">maximize</Key>
<Key mask="A" key="F6">minimize</Key>
<Key mask="CA" key="Right">rdesktop</Key>
<Key mask="CA" key="Left">ldesktop</Key>
<Key mask="CA" key="Up">udesktop</Key>
<Key mask="CA" key="Down">ddesktop</Key>
<Key mask="A" key="F1">root:3</Key>
<Key mask="A" key="F3">window</Key>
<Key mask="A" key="space">window</Key>
<!-- skipps to next occupied screen -->
<Key mask="C|S">Right</Key>
<Action name="GoTo">
<NextOccupied/>
</Action>
<Key mask="C|S">Left</Key>
<Action name="GoTo">
<PrevOccupied/>
</Action>
<Key mask="CA" key="Delete">exec:defaultprocessmanager</Key>
<Key mask="CS" key="Escape">exec:defaultprocessmanager</Key>
<!-- http://wiki.linuxquestions.org/wiki/XF86_keyboard_symbols -->
> <Key keycode="160">exec:amixer sset Master toggle</Key>
> <Key keycode="176">exec:amixer sset Master 1+,1+</Key>
> <Key keycode="174">exec:amixer sset Master 1-,1-</Key>
<Key key="XF86WWW">exec:defaultbrowser</Key>
<Key key="XF86HomePage">exec:defaultbrowser</Key>
<Key key="XF86MonBrightnessUp">exec:brightnessctl set +10%</Key>
<Key key="XF86MonBrightnessDown">exec:brightnessctl set 10%-</Key>
<Key key="Print">exec:defaultscreenshot</Key>
<!-- mod4 Super_L Super_R Hyper_L -->
<Key mask="4" key="e">exec:defaultfilemanager</Key>
<Key mask="4" key="r">exec:defaultrun</Key>
<Key mask="4" key="f">exec:pfind</Key>
<Key mask="4" key="F7">exec:defaultterminal</Key>
<Key mask="4" key="#">desktop#</Key>
<Key mask="4" key="d">showdesktop</Key>
<Key mask="4" key="m">showdesktop</Key>
<Key mask="4" key="l">exec:puplock</Key>
<Key mask="4" key="k">exec:keymap-set</Key>
<Key key="Super_R">root:3</Key>
<Key mask="C" key="Super_L">root:3</Key>
<DefaultIcon>/usr/share/pixmaps/puppy/execute.svg</DefaultIcon>
<Group><Class>Savebox</Class><Option>width:500</Option></Group>
<Group><Name>galculator</Name><Option>centered</Option></Group>
<Mouse context="title" button="4">shade</Mouse><Mouse context="title" button="5">shade</Mouse>
<ButtonClose>/usr/share/pixmaps/close.png</ButtonClose>
<ButtonMax>/usr/share/pixmaps/max.png</ButtonMax>
<ButtonMaxActive>/usr/share/pixmaps/maxact.png</ButtonMaxActive>
<ButtonMin>/usr/share/pixmaps/min.png</ButtonMin>
</JWM>
Will also take a closer look at @MochiMoppel suggestion.
- gychang
- Posts: 591
- Joined: Fri Aug 28, 2020 4:51 pm
- Location: San Diego, CA
- Has thanked: 206 times
- Been thanked: 64 times
Re: keyboard shortcuts to skip empty virtual screen?
MochiMoppel wrote: ↑Sat Apr 01, 2023 7:12 amCode: Select all
#!/bin/sh ## called without argument: switch to next non-empty desktop ## called with any argument: switch to previous non-empty desktop [ $1 ] && REV=-r CDT=$(xprop -root _NET_CURRENT_DESKTOP) CDT=${CDT##* } LST=$(wmctrl -l | awk -v cdt=$CDT '{print $2};END{print cdt}' | sort $REV -un) NXT=$(echo "$LST" | sed -n "/^$CDT$/{n;p}") wmctrl -s $NXT
In my test the script is called "next_dt" and the argument "reverse".
Add to your /root/.jwm/jwmrc-personal file, adjust the path, save the file and then runjwm -restart
Code: Select all
<Key key="Right" mask="CS">exec:/path/to/next_dt</Key> <Key key="Left" mask="CS">exec:/path/to/next_dt reverse</Key>
This works!, just like your other useful codes of some which I use... How can it be modded to rather than using reverse argument just go wrap around screen?. Another words if I am on screen 6 (last screen) and I want to go to screen 1 which has an app running, I like to go "forward" to screen 1, rather than using CS left arrow. This is very helpful.
Re: keyboard shortcuts to skip empty virtual screen?
MochiMoppel has proposed a very clever solution. This is the same code, I've only rewritten it in awk. It can wrap around and uses wmctrl to get the current desktop.
Insert in the jwmrc-personal and restart jwm:
Code: Select all
<Key mask="CA" key="Right"><![CDATA[exec:gawk 'BEGIN{w="wmctrl ";while(w "-d"|getline>0)if($2=="*")r=c=$1;n=$1+1;c=$1-c;while(w "-l"|getline>0)if($2>=0&&($2+c)%n<(r+c)%n)r=$2;system(w "-s" r)}']]></Key>
<Key mask="CA" key="Left"><![CDATA[exec:gawk 'BEGIN{w="wmctrl ";while(w "-d"|getline>0)if($2=="*")r=c=$1;n=$1+1;c=n-c;while(w "-l"|getline>0)if($2>=0&&($2+c)%n>(r+c)%n)r=$2;system(w "-s" r)}']]></Key>
- MochiMoppel
- Posts: 1233
- Joined: Mon Jun 15, 2020 6:25 am
- Location: Japan
- Has thanked: 21 times
- Been thanked: 437 times
Re: keyboard shortcuts to skip empty virtual screen?
There are several ways. This is one of them and even appears to work :
Replace
LST=$(wmctrl -l | awk -v cdt=$CDT '{print $2};END{print cdt}' | sort $REV -un)
NXT=$(echo "$LST" | sed -n "/^$CDT$/{n;p}")
with
LST=$(wmctrl -l | awk -v cdt=$CDT '{if ($2!="-1")print $2};END{print cdt}' | sort $REV -un)
NXT=$(echo -e "$LST\n$LST" | sed -n "/^$CDT$/{n;p;q}")
- gychang
- Posts: 591
- Joined: Fri Aug 28, 2020 4:51 pm
- Location: San Diego, CA
- Has thanked: 206 times
- Been thanked: 64 times
Re: keyboard shortcuts to skip empty virtual screen?
MochiMoppel wrote: ↑Sun Apr 02, 2023 6:53 amThere are several ways. This is one of them and even appears to work :
Replace
LST=$(wmctrl -l | awk -v cdt=$CDT '{print $2};END{print cdt}' | sort $REV -un)
NXT=$(echo "$LST" | sed -n "/^$CDT$/{n;p}")
with
LST=$(wmctrl -l | awk -v cdt=$CDT '{if ($2!="-1")print $2};END{print cdt}' | sort $REV -un)
NXT=$(echo -e "$LST\n$LST" | sed -n "/^$CDT$/{n;p;q}")
works perfectly!!
- MochiMoppel
- Posts: 1233
- Joined: Mon Jun 15, 2020 6:25 am
- Location: Japan
- Has thanked: 21 times
- Been thanked: 437 times
keyboard shortcuts to skip empty virtual screen?
Nothing is perfect
Thanks to ROX's Iconified windows feature my use of minimized windows has increased. This means that desktops with only minimized, but no open windows are not unusual. This made it necessary to modify the script.
The following modified script skips empty desktops and desktops that appear empty (because they only contain minimized windows).
It is now also POSIX compliant, i.e. it can run in a dash shell, apart from bash and busybox ash. Does this make it faster? No
More important is that it doesn't require wmctrl anymore.. and awk is gone. Some "modern" Puppies ship with xdotool but not wmctrl. The script (hopefully!) works with whatever is installed.
Code: Select all
#!/bin/ash
[ $1 ] && REV=-r
LF='
'
XPR=$(xprop -root _NET_CLIENT_LIST _NET_CURRENT_DESKTOP)
CDT=${XPR#*= } # Desktop No. of current desktop (base 0)
NCL=${XPR%$LF*} # cut 2nd line to get NET_CLIENT_LIST
NCL=${NCL#*\# } # all window IDs, e.g. 0x2400081, 0x48abec, 0x48abef ...
for WID in $NCL;do
XPR=$(xprop -id ${WID%,} _NET_WM_STATE _NET_WM_DESKTOP) # stripping comma from WID not really necessary, xprop would ignore trailing junk
case "$XPR" in (*_NET_WM_STATE_HIDDEN*|*_NET_WM_STATE_STICKY*) continue;; esac # skip sticky and minimized
LST=$LST${XPR##*= }$LF # list of all desktops containing open windows
done
LST=$(echo "$LST$CDT" | sort $REV -un) # make sure that CDT is part of sorted LST
NXT=$(echo "$LST$LF$LST" | sed -n "/^$CDT$/{n;p;q}") # duplicate LST to let sed wrap around when last desktop reached
xdotool set_desktop $NXT || wmctrl -s $NXT # jump to next desktop, using xdotool or wmctrl