Views:
4,419β
Votes: 6β
β
Solution
Tags:
command-line
bash
gnome-shell
window-manager
xdotool
Link:
π See Original Question on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1147294
Title:
xdotool how to select desktop send F5 and return?
ID:
/2019/05/30/xdotool-how-to-select-desktop-send-F5-and-return_
Created:
May 30, 2019
Edited: May 31, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
It sounds simple; xdotool
selects desktop, simulates F5 key press and returns focus to calling window / program.
After googling though it doesnβt sound simple anymore.
I need to do this from bash / gnome-shell.
Any ideas?
This project is related to this Q&A where the icons drop off the left screen into a black whole because of different sized monitors:
Thanks to Podestaβs help I created this code:
TestIcons () {
[[ $TestSeconds == "" ]] || [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<${#IconsArr[@]}; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"${IconsArr[((i+ICON_NAME_NDX))]}"
Position="${IconsArr[((i+ICON_COL_NDX))]},${IconsArr[((i+ICON_ROW_NDX))]}"
gvfs-set-attribute -t string "$File" \
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<${#OldIconsArr[@]}; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"${OldIconsArr[((i+ICON_NAME_NDX))]}"
Position="${OldIconsArr[((i+ICON_COL_NDX))]},${OldIconsArr[((i+ICON_ROW_NDX))]}"
gvfs-set-attribute -t string "$File" \
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
} # TestIcons
This is what the screen looks like: