Difference between revisions of "Talk:Xdotool"
From Free Knowledge Base- The DUCK Project: information for everyone
(Created page with " xmodmap -pme") |
(→minimize all other windows: new section) |
||
(2 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
xmodmap -pme | xmodmap -pme | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | read this | ||
+ | * https://theembeddedlab.com/tutorials/simulate-keyboard-mouse-events-xdotool-raspberry-pi/ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | The name of the button can be found this way: run xev, then press the button and the name shows up in the brackets. In my case it was this: keycode 135 (keysym 0xff67, Menu), here Menu is the name of the key. | ||
+ | |||
+ | Then I could run xdotool Menu. However to make it work with a custom shortcut I had to add sleep before it, so I ended up with this code: | ||
+ | |||
+ | sleep 0.5 && xdotool key 'Menu' | ||
+ | sleep 0.01 && xdotool key 's' | ||
+ | sleep 0.01 && xdotool key 'e' | ||
+ | |||
+ | == move the focused window in X to different parts of the screen == | ||
+ | |||
+ | #!/bin/bash | ||
+ | |||
+ | # Written by Andrew McDonough | ||
+ | # A simple bash script that uses xdotool to move the window that is currently in focus to different parts of the screen. | ||
+ | # Particularly useful for reading web pages with flexible layouts on wide monitors. | ||
+ | # Assign the various options to keyboard shortcuts e.g. '<Super>Left' assigned to 'swind left' | ||
+ | # See http://tinyurl.com/ubuntukeys for help with assigning keyboard shortcuts. | ||
+ | |||
+ | # Change the following to suit your own monitor's resolution. Mine is 1920x1200 | ||
+ | width=1920 | ||
+ | height=1200 | ||
+ | |||
+ | winid=`xdotool getwindowfocus` | ||
+ | |||
+ | case "$1" in | ||
+ | '') | ||
+ | echo "Usage: swind <left|right|top|bottom|top-left|top-right|bottom-left|bottom-right>" | ||
+ | ;; | ||
+ | 'left') | ||
+ | xdotool windowmove $winid 0 0 | ||
+ | xdotool windowsize $winid $(( $width/2 )) $height | ||
+ | ;; | ||
+ | 'right') | ||
+ | xdotool windowmove $winid $(( $width/2)) 0 | ||
+ | xdotool windowsize $winid $(( $width/2)) $height | ||
+ | ;; | ||
+ | 'top') | ||
+ | xdotool windowmove $winid 0 0 | ||
+ | xdotool windowsize $winid $width $(( $height/2 )) | ||
+ | ;; | ||
+ | 'bottom') | ||
+ | xdotool windowmove $winid 0 $(( $height/2 )) | ||
+ | xdotool windowsize $winid $width $(( $height/2 )) | ||
+ | ;; | ||
+ | 'top-left') | ||
+ | xdotool windowmove $winid 0 0 | ||
+ | xdotool windowsize $winid $(( $width/2 )) $(( $height/2)) | ||
+ | ;; | ||
+ | 'top-right') | ||
+ | xdotool windowmove $winid $(( $width/2)) 0 | ||
+ | xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | ||
+ | ;; | ||
+ | 'bottom-left') | ||
+ | xdotool windowmove $winid 0 $(( $width/2 )) | ||
+ | xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | ||
+ | ;; | ||
+ | 'bottom-right') | ||
+ | xdotool windowmove $winid $(( $width/2)) $(( $height/2 )) | ||
+ | xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | == minimize all other windows == | ||
+ | |||
+ | #!/bin/bash | ||
+ | |||
+ | active_window_id=$(xdotool getactivewindow) | ||
+ | for window_id in $(xdotool search --onlyvisible ".*") | ||
+ | do | ||
+ | if [ $window_id != $active_window_id ] | ||
+ | then | ||
+ | xdotool windowminimize $window_id | ||
+ | fi | ||
+ | done |
Latest revision as of 23:04, 5 July 2020
xmodmap -pme
read this
The name of the button can be found this way: run xev, then press the button and the name shows up in the brackets. In my case it was this: keycode 135 (keysym 0xff67, Menu), here Menu is the name of the key.
Then I could run xdotool Menu. However to make it work with a custom shortcut I had to add sleep before it, so I ended up with this code:
sleep 0.5 && xdotool key 'Menu' sleep 0.01 && xdotool key 's' sleep 0.01 && xdotool key 'e'
move the focused window in X to different parts of the screen
- !/bin/bash
- Written by Andrew McDonough
- A simple bash script that uses xdotool to move the window that is currently in focus to different parts of the screen.
- Particularly useful for reading web pages with flexible layouts on wide monitors.
- Assign the various options to keyboard shortcuts e.g. '<Super>Left' assigned to 'swind left'
- See http://tinyurl.com/ubuntukeys for help with assigning keyboard shortcuts.
- Change the following to suit your own monitor's resolution. Mine is 1920x1200
width=1920 height=1200
winid=`xdotool getwindowfocus`
case "$1" in )
echo "Usage: swind <left|right|top|bottom|top-left|top-right|bottom-left|bottom-right>"
'left')
xdotool windowmove $winid 0 0 xdotool windowsize $winid $(( $width/2 )) $height
'right')
xdotool windowmove $winid $(( $width/2)) 0 xdotool windowsize $winid $(( $width/2)) $height
'top')
xdotool windowmove $winid 0 0 xdotool windowsize $winid $width $(( $height/2 ))
'bottom')
xdotool windowmove $winid 0 $(( $height/2 )) xdotool windowsize $winid $width $(( $height/2 ))
'top-left')
xdotool windowmove $winid 0 0 xdotool windowsize $winid $(( $width/2 )) $(( $height/2))
'top-right')
xdotool windowmove $winid $(( $width/2)) 0 xdotool windowsize $winid $(( $width/2 )) $(( $height/2 ))
'bottom-left')
xdotool windowmove $winid 0 $(( $width/2 )) xdotool windowsize $winid $(( $width/2 )) $(( $height/2 ))
'bottom-right')
xdotool windowmove $winid $(( $width/2)) $(( $height/2 )) xdotool windowsize $winid $(( $width/2 )) $(( $height/2 ))
esac
minimize all other windows
- !/bin/bash
active_window_id=$(xdotool getactivewindow) for window_id in $(xdotool search --onlyvisible ".*") do
if [ $window_id != $active_window_id ] then xdotool windowminimize $window_id fi
done