ubuntu16.04下xfce4下快速显示桌面的快捷键设置

来源:互联网 发布:李逵打鱼版本源码 编辑:程序博客网 时间:2024/06/01 03:57

转载自

http://www.linuxdiyf.com/linux/21629.html

apt-get install xdotool

然后

#!/bin/bash#todo:# cancel for tile functions# determine what windows are maximized and re-max after the "window select" function# determine what windows are non-resizable by the user so that the script doesn't resize them# cascade also shaded windows# which workspace we're onfunction get_workspace {if [[ "$DTOP" == "" ]] ; thenDTOP=`xdotool get_desktop`fi}function is_desktop {xwininfo -id "$*" | grep '"Desktop"'return "$?"}function get_visible_window_ids {if (( ${#WDOWS[@]} == 0 )) ; thenWDOWS=(`xdotool search --desktop $DTOP --onlyvisible "" 2>/dev/null`)fi}function get_desktop_dim {#desktop dimensionsif (( ${#DIM[@]} == 0 )) ; thenDIM=(`wmctrl -d | egrep "^0" | sed 's/.*DG: \([0-9]*x[0-9]*\).*/\1/g' | sed 's/x/ /g'`)fi}function win_showdesktop {get_workspaceget_visible_window_idscommand="search --desktop $DTOP \"\""if (( ${#WDOWS[@]} > 0 )) ; thencommand="$command windowminimize %@"elsecommand="$command windowraise %@"fiecho "$command" | xdotool -}function win_tile_two {get_desktop_dimwid1=`xdotool selectwindow 2>/dev/null`is_desktop "$wid1" && returnwid2=`xdotool selectwindow 2>/dev/null`is_desktop "$wid2" && returnhalf_w=`expr ${DIM[0]} / 2`commands="windowsize $wid1 $half_w ${DIM[1]}"commands="$commands windowsize $wid2 $half_w ${DIM[1]}"commands="$commands windowmove $wid1 0 0"commands="$commands windowmove $wid2 $half_w 0"commands="$commands windowraise $wid1"commands="$commands windowraise $wid2"wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horzwmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horzecho "$commands" | xdotool -}function win_tile {get_workspaceget_visible_window_ids(( ${#WDOWS[@]} < 1 )) && return;get_desktop_dim# determine how many rows and columns we needcols=`echo "sqrt(${#WDOWS[@]})" | bc`rows=$colswins=`expr $rows \* $cols`if (( "$wins" < "${#WDOWS[@]}" )) ; thencols=`expr $cols + 1`wins=`expr $rows \* $cols`if (( "$wins" < "${#WDOWS[@]}" )) ; thenrows=`expr $rows + 1`wins=`expr $rows \* $cols`fifi(( $cols < 1 )) && cols=1;(( $rows < 1 )) && rows=1;win_w=`expr ${DIM[0]} / $cols`win_h=`expr ${DIM[1]} / $rows`# do tilingx=0; y=0; commands=""for window in ${WDOWS[@]} ; dowmctrl -i -r $window -b remove,maximized_vert,maximized_horzcommands="$commands windowsize $window $win_w $win_h"commands="$commands windowmove $window `expr $x \* $win_w` `expr $y \* $win_h`"x=`expr $x + 1`if (( $x > `expr $cols - 1` )) ; thenx=0y=`expr $y + 1`fidoneecho "$commands" | xdotool -}function win_cascade {get_workspaceget_visible_window_ids(( ${#WDOWS[@]} < 1 )) && return;x=0; y=0; commands=""for window in ${WDOWS[@]} ; dowmctrl -i -r $window -b remove,maximized_vert,maximized_horzcommands="$commands windowsize $window 640 480"commands="$commands windowmove $window $x $y"x=`expr $x + 22`y=`expr $y + 22`doneecho "$commands" | xdotool -}function win_select {get_workspaceget_visible_window_ids(( ${#WDOWS[@]} < 1 )) && return;# store window positions and widthsi=0for window in ${WDOWS[@]} ; doGEO=`xdotool getwindowgeometry $window | grep Geometry | sed 's/.* \([0-9].*\)/\1/g'`;height[$i]=`echo $GEO | sed 's/\(.*\)x.*/\1/g'`width[$i]=`echo $GEO | sed 's/.*x\(.*\)/\1/g'`# ( xwininfo gives position not ignoring titlebars and borders, unlike xdotool )POS=(`xwininfo -stats -id $window | grep 'geometry ' | sed 's/.*[-+]\([0-9]*[-+][0-9*]\)/\1/g' | sed 's/[+-]/ /g'`)posx[$i]=${POS[0]}posy[$i]=${POS[1]}i=`expr $i + 1`done# tile windowswin_tile# select a windowwid=`xdotool selectwindow 2>/dev/null`is_desktop "$wid" && return# restore window positions and widthsi=0; commands=""for (( i=0; $i<${#WDOWS[@]}; i++ )) ; docommands="$commands windowsize ${WDOWS[i]} ${height[$i]} ${width[$i]}"commands="$commands windowmove ${WDOWS[i]} ${posx[$i]} ${posy[$i]}"donecommands="$commands windowraise $wid"echo "$commands" | xdotool -}for command in ${@} ; doif [[ "$command" == "tile" ]] ; thenwin_tileelif [[ "$command" == "select" ]] ; thenwin_selectelif [[ "$command" == "tiletwo" ]] ; thenwin_tile_twoelif [[ "$command" == "cascade" ]] ; thenwin_cascadeelif [[ "$command" == "showdesktop" ]] ; thenwin_showdesktopfidone

保存为winfuncs.sh

保存在以下路径,如下:

/home/appleyuchi/CommandForShortCut/winfuncs.sh

chmod u+x/home/appleyuchi/CommandForShortCut/winfuncs.sh

Applications=>Settings=>Keyboard=>Application Shortcuts

1、Add

2、Command中输入/home/appleyuchi/CommandForShortCut/winfuncs.sh showdesktop

点击OK

3、弹出对画框,按下windows键+D即可

4、回到Keyboard对话框,按下close即可。

此时桌面上按下windows+D即可显示桌面,再按一次可以恢复


0 0
原创粉丝点击