Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ I use the desktop environment in GNU / Linux combination tool     - systemd-nspawn Quick Guide (Linux)

- VMware installed Linux system and JDK deployment (Linux)

- CentOS7 + Redis Live Installation and Configuration (Linux)

- Compile and install LNMP under CentOS 6.5 (Server)

- GDB remote connections RX Probe online debug program (Programming)

- Build the first ASP.NET 5 Web project in Mac OS X Yosemite 10.10.3 (Server)

- Linux System Getting Started Learning: rename multiple files in Linux (Linux)

- Use Oracle 11g show spparameter command (Database)

- Windows SmartGit installation (Linux)

- In Spring AOP example explanation (Programming)

- Solaris 10 installation configuration mrtg monitoring system (Linux)

- Install MATE desktop environment adjustment tools Mate Tweak 3.3.6 (Linux)

- Use Ambari rapid deployment Hadoop big data environment (Server)

- Install JDK 1.7 + Eclipse in CentOS 6.4 in (Linux)

- Spark parquet merge metadata problem (Server)

- Boot automatically remove Linux operating history records (Linux)

- innodb storage engine backup tool --Xtrabackup (Database)

- Using iptables achieve NAT (Linux)

- Linux install the Java Runtime Environment and the output Hello World under (CentOS) (Linux)

- How to install Linux Go Language (Linux)

 
         
  I use the desktop environment in GNU / Linux combination tool
     
  Add Date : 2016-04-23      
         
         
         
  In order to make GNU / Linux desktop environment under less loaded in order to save memory resources and improve start-up time, I currently do not use heavyweight desktop environment KDE and Gnome, even the login window interface gdm or xdm do not have, but directly start to console, calling startx after logging into the X window environment. Tools used in combination are listed below:

X Window environment starts: startx
Window Manager: Sawfish
amixer: System volume settings
Keyboard and mouse configuration: xmodmap
Network Manager: wicd (to be deleted NetworkManager)
xscreensaver: Screen Saver
Bottom toolbar similar to the Windows: perlpanel
shutter: screenshot tool
amor: Screen Pet Toys
workrave: regular breaks, event reminders tool used to relieve visual fatigue, physical fatigue
xclock: Desktop analog or digital clock
knotes: Desktop sticky notes
Audio settings in ~ / .bashrc

First introduced when logging on to the console, in ~ / .bashrc some environment variables are defined, they will start after the X Window, the amixer command for system volume control.

# Default sound device
export DEFAULT_SOUND = numid = 3, iface = MIXER, name = " 'Master Playback Volume'"
# Max sound for the two channels supported by the sound card
declare -i MAX_SOUND_VOLUME
export MAX_SOUND_VOLUME = 65536
# Default sound volume percentage for the two channels when starting X window
declare -i DEFAULT_LSOUND_VOLUME_PERCENTAGE DEFAULT_RSOUND_VOLUME_PERCENTAGE
export DEFAULT_LSOUND_VOLUME_PERCENTAGE = 40
export DEFAULT_RSOUND_VOLUME_PERCENTAGE = 40
# Default sound volume for the two channels when starting X window
declare -i DEFAULT_LSOUND_VOLUME DEFAULT_RSOUND_VOLUME
export DEFAULT_LSOUND_VOLUME = $ (($ MAX_SOUND_VOLUME * $ DEFAULT_LSOUND_VOLUME_PERCENTAGE / 100))
export DEFAULT_RSOUND_VOLUME = $ (($ MAX_SOUND_VOLUME * $ DEFAULT_RSOUND_VOLUME_PERCENTAGE / 100))
# Whether play init sound when starting X window
export STARTX_INIT_SOUND = 1

# Aliases for starting X with or without sound
alias xs = "export STARTX_INIT_SOUND = 1; startx"
alias xq = "export STARTX_INIT_SOUND = 0; startx"

Explanation for the above code is as follows:

1. DEFAULT_SOUND variable contains the specified operating system ALSA sound drivers tuner device number and name. amixer to the value parameter, you can control the corresponding audio. The device information can be executed from the command line amixer contents displayed, as shown below. As can be seen, the default audio device minimum volume of 0 and a maximum of 65536 (2 bytes), the minimum amount of adjustment is 1, the current left and right channel volume values ​​are 17790.

numid = 4, iface = MIXER, name = 'Master Playback Switch'
  ; Type = BOOLEAN, access = rw ------, values ​​= 1
  : Values ​​= on
numid = 3, iface = MIXER, name = 'Master Playback Volume'
  ; Type = INTEGER, access = rw ------, values ​​= 2, min = 0, max = 65536, step = 1
  : Values ​​= 17790,17790
numid = 2, iface = MIXER, name = 'Capture Switch'
  ; Type = BOOLEAN, access = rw ------, values ​​= 1
  : Values ​​= on
numid = 1, iface = MIXER, name = 'Capture Volume'
  ; Type = INTEGER, access = rw ------, values ​​= 2, min = 0, max = 65536, step = 1
  : Values ​​= 28174,28174

2. MAX_SOUND_VOLUME variable stores the maximum volume value 65536.

3. DEFAULT_LSOUND_VOLUME_PERCENTAGE and DEFAULT_RSOUND_VOLUME_PERCENTAGE were left, right channel default volume percentage, currently set to 40%.

4. DEFAULT_LSOUND_VOLUME DEFAULT_RSOUND_VOLUME were left with default integer values ​​right channel volume.

5. STARTX_INIT_SOUND variable 1, when calling startx into the X Window, the music will automatically play welcome; to 0 is not played. Play command provided by ~ / .xinitrc.

6. Create two aliases, xs playing welcome music when calling startx is, xq is not played.

Setting ~ / .xinitrc

At the console login, with ~ / .bashrc settings, you can call or xq xs start startx into the X Window windowing environment. During startup configuration and load the necessary procedures are set up in ~ / .xinitrc in. Which reads as follows:

# Export ibus environment variables
export XMODIFIERS = @ im = ibus
export GTK_IM_MODULE = ibus
export QT_IM_MODULE = ibus

# Load NVIDIA configurations
nvidia-settings --load-config-only

# Load keyboard and mouse configurations
xmodmap ~ / .xmodmaprc &
# Load X server resources
xrdb ~ / .Xresources &

# Load image (s) as desktop wallpaper
# Set_wallpaper.sh -r 0 -w 1920 -h 1080 -x 1280 -y 0 $ picture / wallpapers / sunflower.jpg &
set_multi_wallpapers.sh -t 300 &
# Set the default sound volume
amixer cset numid = 3, iface = MIXER, name = 'Master Playback Volume' $ DEFAULT_LSOUND_VOLUME, $ DEFAULT_RSOUND_VOLUME &
# Play welcome sound: Steve Jobs' speech
if [ "$ STARTX_INIT_SOUND" = 1]; then
    mplayer $ music / speech / steve \ jobs \ in \ harvard \ clip.mp3 / dev / null &
fi

# Adjust touchpad pressure sensitivity
if [ "$ cur_host_name" = "QuantumBoy"]; then
    synclient PressureMotionMinZ = 8
    synclient PressureMotionMaxZ = 80
fi

# Start window manager
sawfish --display =: 0

Explanation for the above code is as follows:

1. Export ibus input method related environment variables.

2. Run nvidia-settings to load NVIDIA configuration.

3. Use xmodmap to load keyboard and mouse configuration, mainly exchange Caps Lock and left Control key, switching left and right mouse button. See details here.

4. Use xrdb to load Windows resource file ~ / .Xresources, wherein the X display parameters for different programs, set the cursor theme. Which reads as follows:

Xcursor.theme: oxy-green
XClock.Clock.hourColor: red
XClock.Clock.minuteColor: green
XClock.Clock.minorColor: blue
XClock.Clock.majorColor: black

5. Start set_multi_wallpapers.sh script loads dynamic wallpaper, or call set_wallpaper.sh loaded single wallpaper.

6. Use amixer set the system default volume. Volume value of left and right channels from the environment variable DEFAULT_LSOUND_VOLUME and DEFAULT_RSOUND_VOLUME.

7. The environment variable STARTX_INIT_SOUND add value to determine whether to start the audio playback. Currently, I play Steve Jobs said stay hungray, stay foolish those remarks.

8. The host name of the computer to determine if you are using your own laptop ZaReason Ultralap 440, then execute the command synclient Setting TouchPad pressure threshold.

9. Finally, start the Sawfish window manager.

Sawfish settings: ~ / .sawfishrc

Sawfish is a lightweight window manager, use the Lisp language librep library support based on its configuration: includes window display properties, the shortcut key bindings, etc. So, in fact, the so-called lightweight high-performance, resource saving, but its function can be programmed configuration was very powerful. Here I configure it in ~ / .sawfishrc file. The main function can be achieved:

1. The common program is bound to a shortcut. When you press the shortcut key associated with the program if not started, start it and then put the front end; otherwise start, it is promoted to the front end. Implement this function depends on the jump-or-exec module. With this feature, you do not frequently use the mouse to switch between different windows, and very convenient. Currently, I am bound to shortcut keys are as follows:

Win + 1: command-line terminal program Konsole;
Win + 2: file manager Dolphin;
Win + 3: text editor Emacs;
Win + 4: multi-language electronic dictionary Stardict or Goldendict;
Win + 5: Web browser Iceweasel, which is the name of Mozilla Firefox in the Debian;
Win + 6: mail client (also a RSS reader, calendar, task management, similar to Microsoft Outlook) Icedove, it is Mozilla Thunderbird in Debian's name;
Win + 7: office software LibreOffice;
Win + 8: picture, photo viewer Gwenview. The software under Windows than the picture viewer much better: You can see the animated GIF, you can also see the video directly;
Win + 9: audio player Audacious, play lossless music ape, flac's choice;
Win + 0: call tv_nomen.sh script playback cable, see here.
Code above functions and settings are as follows. Wherein the display-close-message function is used to display on the screen the name of the program has been started, information feedback to the user, and automatically turns off after a specified time.

;; Load jump-or-exec module
(Require 'jump-or-exec)

;; Display a message which can automatically disappear
(Defun display-close-message (message seconds & optional attributes)
  "Display MESSAGE for SECONDS seconds and make the message disappeared.
The default display-message do not close the message window automatically "
  (Interactive)
  (Display-message message attributes)
  (Make-timer
  (Lambda ()
    (Display-message)) seconds))

;; KDE terminal konsole
(Bind-keys global-keymap
    "Super-1" `(jump-or-exec" ^ Konsole @ "
        , (Lambda ()
          (Display-close-message "Start KDE terminal ..." alert-msg-time alert-msg-attrib)
          (System "konsole &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Dolphin file manager
(Bind-keys global-keymap
    "Super-2" `(jump-or-exec" Dolphin $ "
        , (Lambda ()
          (Display-close-message "Start Dolphin file manager ..." alert-msg-time alert-msg-attrib)
          (System "dolphin &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Emacs text editor
(Bind-keys global-keymap
    "Super-3" `(jump-or-exec" ^ Emacs @ "
        , (Lambda ()
          (Display-close-message "Start Emacs text editor ..." alert-msg-time alert-msg-attrib)
          (System "emacs &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Stardict
(Bind-keys global-keymap
    "Super-4" `(jump-or-exec" ^ StarDict $ "
        , (Lambda ()
          (Display-close-message "Start Stardict electronic dictionary ..." alert-msg-time alert-msg-attrib)
          (System "stardict &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Iceweasel
(Bind-keys global-keymap
    "Super-5" `(jump-or-exec" Iceweasel $ "
        , (Lambda ()
          (Display-close-message "Start Iceweasel web browser ..." alert-msg-time alert-msg-attrib)
          (System "iceweasel &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Icedove
(Bind-keys global-keymap
    "Super-6" `(jump-or-exec" (Mozilla Thunderbird) | (Icedove) "
        , (Lambda ()
          (Display-close-message "Start Icedove mail and news ..." alert-msg-time alert-msg-attrib)
          (System "icedove &"))
        , (Lambda (wind)
          (Display-window wind))))

;; LibreOffice
(Bind-keys global-keymap
    "Super-7" `(jump-or-exec" LibreOffice "
        , (Lambda ()
          (Display-close-message "Start LibreOffice ..." alert-msg-time alert-msg-attrib)
          (System "libreoffice &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Gwenview
(Bind-keys global-keymap
    "Super-8" `(jump-or-exec" Gwenview $ "
        , (Lambda ()
          (Display-close-message "Start Gwenview image viewer ..." alert-msg-time alert-msg-attrib)
          (System "gwenview &"))
        , (Lambda (wind)
          (Display-window wind))))

;; Audacious
(Bind-keys global-keymap
    "Super-9" `(jump-or-exec" Audacious "
        , (Lambda ()
          (Display-close-message "Start Audacious music player ..." alert-msg-time alert-msg-attrib)
          (System "audacious &"))
        , (Lambda (wind)
          (Display-window wind))))

;; TV
(Bind-keys global-keymap
    "Super-0" `(jump-or-exec" MPlayer TV "
        , (Lambda ()
          (Display-close-message "Start TV ..." alert-msg-time alert-msg-attrib)
          (System "tv_nomen.sh &"))
        , (Lambda (wind)
          (Display-window wind))))

2. When entering the X Window automatically loads the specified program, the equivalent of Windows since the launch of the project. I load the current program are:

ibus input method;
Network manager wicd-gtk;
Click touchpad allows script enable_tapbutton.sh (valid only on my laptop ZaReason Ultralap 440);
xscreensaver screen saver, which contains a very cool screensaver effects, I am currently using 3D Matrix;
Bottom toolbar similar to the Windows: perlpanel
shutter: screenshot tool
amor: Screen Pet Toys
workrave: regular breaks, event reminders tool used to relieve visual fatigue, physical fatigue
xclock: Desktop analog or digital clock
knotes: Desktop sticky notes
Related code is as follows:

;; Define startup programs
(Setq startup-programs
  '(
    ;; Start ibus input method: -x option starts ibus XIM server, -r option
    ;; Replaces existing daemon. In addition, the following environment
    ;; Variables should be set, otherwise, KDE programs can not use ibus input
    ;; Method.
    ( "Ibus-daemon" "-xrd")
    ;; Start wicd network manager
    ( "Wicd-gtk" "-t")
    ;; Enable touchpad tapping
    ( "Enable_tapbutton.sh")
    ;; Start screensaver
    ( "Xscreensaver" "-no-splash")
    ;; Start panel
    ( "Perlpanel")
    ;; Start Shutter for taking snapshots
    ( "Shutter")
    ;; Start amor toy: white kitty
    ( "Amor")
    ;; Start xclock
    ( "Xclock")
    ;; Start knotes
    ( "Knotes")
    ;; Start workrave
    ( "Workrave")))

;; Execute startup programs one by one
(Mapc (lambda (program)
        (Apply start-process (make-process standard-output) program))
      startup-programs)

;; Make sure active processes are killed before sawfish exits
(Add-hook 'before-exit-hook
          (Lambda ()
            (Mapc stop-process (active-processes))))

3. Volume Control: Volume Control shortcut key bindings currently as follows

Win +]: run volume-up-by-ratio, increase the volume of 1%
Win + [: Run volume-down-by-ratio, decrease the volume of 1%
Win + \: run toggle-volume-mute, in between the current volume when the mute switch
Sawfish its associated function calls amixer command to complete the specified operation. Specific Buyers amixer help. Sawfish code is as follows:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;
;; System sound volume related variables and functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;
(Setq max-volume (string-> number (getenv "MAX_SOUND_VOLUME")))
(Setq min-volume 0)
(Setq current-left-volume 0)
(Setq current-right-volume 0)
(Setq left-volume-before-mute 0)
(Setq right-volume-before-mute 0)
(Setq volume-adjust-ratio-step 0.01)
(Setq toggle-mute-flag nil)

;; Get volume for both left and right channels and store them into variables
(Defun get-volume ()
  "Get the volume string"
  (Interactive)
  (Let * ((res-stream (make-string-output-stream))
  (Proc (make-process res-stream))
  (Res-str)
  (Res-str-splitted))
    (Call-process proc nil "/usr/local/bin/scripts/get_volume.sh")
    (Setq res-str (get-output-stream-string res-stream))
    (Setq res-str-splitted (string-split "," (substring res-str 0 (- (length res-str) 1))))
    (Setq current-left-volume (string-> number (nth 0 res-str-splitted)))
    (Setq current-right-volume (string-> number (nth 1 res-str-splitted)))))
(Get-volume)

;; Get volume percentage string
(Defun get-volume-percentage-str (vol)
  "Get the percentage of the specified volume quantity in string format"
  (Interactive)
  (Concat (number-> string (round (* (/ vol max-volume) 100))) "%"))

;; Set volume by ratio
(Defun set-volume-by-ratio (lft-vol rt-vol)
  "Set volume by percentage"
  (Interactive)
  (System (concat "amixer cset" (getenv "DEFAULT_SOUND") "" (number-> string (* max-volume lft-vol)) "," (number-> string (* max-volume rt-vol)) " & "))
  (Get-volume))

;; Set volume by value
(Defun set-volume-by-value (lft-vol rt-vol)
  "Set volume by value"
  (Interactive)
  (System (concat "amixer cset" (getenv "DEFAULT_SOUND") "" (number-> string lft-vol) "," (number-> string rt-vol) "&"))
  (Get-volume))

;; Increase volume by ratio
(Defun volume-up-by-ratio (vol)
  "Increase volume by ratio"
  (Interactive)
  (Let ((tmp-lft-vol)
 (Tmp-rt-vol))
    (Get-volume)
    (Setq tmp-lft-vol (+ current-left-volume (* max-volume vol)))
    (Setq tmp-rt-vol (+ current-right-volume (* max-volume vol)))
    ;; Detect if the volume is larger than max-volume
    (If (> tmp-lft-vol max-volume)
 (Setq tmp-lft-vol max-volume))
    (If (> tmp-rt-vol max-volume)
 (Setq tmp-rt-vol max-volume))
    
    (Set-volume-by-value tmp-lft-vol tmp-rt-vol)))

;; Decrease volume by ratio
(Defun volume-down-by-ratio (vol)
  "Decrease volume by ratio"
  (Interactive)
  (Let ((tmp-lft-vol)
 (Tmp-rt-vol))
    (Get-volume)
    (Setq tmp-lft-vol (- current-left-volume (* max-volume vol)))
    (Setq tmp-rt-vol (- current-right-volume (* max-volume vol)))
    ;; Detect if the volume is smaller than min-volume
    (If (  (Setq tmp-lft-vol min-volume))
    (If (  (Setq tmp-rt-vol min-volume))
    
    (Set-volume-by-value tmp-lft-vol tmp-rt-vol)))

;; Mute volume
(Defun volume-mute ()
  "Mute system sound"
  (Interactive)
  (Set-volume-by-value min-volume min-volume))

;; Unmute volume
(Defun volume-unmute ()
  "Unmute system sound"
  (Interactive)
  (Set-volume-by-value left-volume-before-mute right-volume-before-mute))

;; Full volume
(Defun volume-max ()
  "Set to max sound volume"
  (Interactive)
  (Set-volume-by-value max-volume max-volume))

;; Toggle mute
(Defun toggle-volume-mute ()
  "Toggle between current sound volume and mute"
  (Interactive)
  (Get-volume)
  (If (and (= current-left-volume min-volume) (= current-right-volume min-volume))
      (If toggle-mute-flag
  (Progn
    (Volume-unmute)
    (Setq toggle-mute-flag nil)
    (Display-close-message (concat "Sound restored to L:" (get-volume-percentage-str current-left-volume) "R:" (get-volume-percentage-str current-right-volume)) alert- msg-short-time alert-msg-attrib)))
    (Progn
      (Setq left-volume-before-mute current-left-volume)
      (Setq right-volume-before-mute current-right-volume)
      (Volume-mute)
      (Setq toggle-mute-flag t)
      (Display-close-message "Mute" alert-msg-short-time alert-msg-attrib))))

;; Increase sound volume
(Bind-keys global-keymap
    "Super-]" `(progn
   (Volume-up-by-ratio volume-adjust-ratio-step)
   (Display-close-message (concat "Volume L:" (get-volume-percentage-str current-left-volume) "R:" (get-volume-percentage-str current-right-volume)) alert-msg- short-time alert-msg-attrib)))

;; Decrease sound volume
(Bind-keys global-keymap
    "Super- [" `(progn
   (Volume-down-by-ratio volume-adjust-ratio-step)
   (Display-close-message (concat "Volume L:" (get-volume-percentage-str current-left-volume) "R:" (get-volume-percentage-str current-right-volume)) alert-msg- short-time alert-msg-attrib)))

;; Toggle sound mute and unmute
(Bind-keys global-keymap
    "Super - \\" `(toggle-volume-mute))

 

The above code is also used in the script I have written get_volume.sh system used to obtain the current volume, as follows:

#! / Bin / bash

amixer cget $ DEFAULT_SOUND | gawk '{if (match ($ 0, / values ​​= ([[: digit:]] +, [[: digit:]] +) /, res) = 0!) print res [1]; } '

4. Turn off the screen saver is activated: when the movies do not start the screen saver, so the need for such a function. Shortcut key bindings for the Win + p. Related configuration is as follows.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;; Xscreensaver related variables and functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
(Setq xscreensaver-enabled t)

(Defun enable-xscreensaver ()
  "Enable xscreensaver"
  (Interactive)
  (System "exec / usr / bin / xscreensaver -no-splash &")
  (Setq xscreensaver-enabled t))

(Defun disable-xscreensaver ()
  "Disable xscreensaver"
  (Interactive)
  (System "exec / usr / bin / xscreensaver-command -exit &")
  (Setq xscreensaver-enabled nil))

(Defun toggle-xscreensaver-activation ()
  "Activate / deactivate xscreensaver"
  (Interactive)
  (If xscreensaver-enabled
      (Disable-xscreensaver)
    (Enable-xscreensaver)))

(Bind-keys global-keymap
    "Super-p" `(progn
   (Toggle-xscreensaver-activation)
   (If xscreensaver-enabled
      (Display-close-message "Screensaver enabled!" Alert-msg-short-time alert-msg-attrib)
    (Display-close-message "Screensaver disabled!" Alert-msg-short-time alert-msg-attrib))))

5. Close and activate the touchpad buttons (valid only for laptops), shortcut key is Win + z. Related configuration is as follows:

;;;;;;;;;;;;;;;;;;;; ;;
;; Touchpad operation
;;;;;;;;;;;;;;;;;;;; ;;
(Setq tapbutton-enabled t)
;; Toggle tap button function of the touchpad
(Bind-keys global-keymap
    "Super-z" `(progn
   (System "toggle_tapbutton.sh &")
   (Setq tapbutton-enabled (not tapbutton-enabled))
   (If tapbutton-enabled
      (Display-close-message "Tap button enabled!" Alert-msg-short-time alert-msg-attrib)
    (Display-close-message "Tap button disabled!" Alert-msg-short-time alert-msg-attrib))))

 

Which calls write your own scripts toggle_tapbutton.sh and enable_tapbutton.sh, the contents of which are as follows:

 

#! / Bin / bash

script_name = "toggle_tapbutton.sh"
script_usage = $ (cat << EOF
$ Script_name
EOF
)
script_function = $ (cat << EOF
This script is used to disable / enable the finger tap function of Synaptics touchpad.
EOF
)
script_doc = $ (cat << EOF
-h Display this help.
EOF
)
script_examples = $ (cat << EOF
EOF
)
state_prefix = "==="
warning_prefix = "***"
error_prefix = "!!!"

function display_help () {
    if [-n "$ script_usage"]; then
    echo -e "Usage: $ script_usage"
    fi

 if [-n "$ script_function"]; then
    echo -e "$ script_function"
    fi
    
    if [-n "$ script_doc"]; then
    echo -e "\ n $ script_doc"
    fi
    
    if [-n "$ script_examples"]; then
    echo -e "\ nExamples"
    echo -e "$ script_examples"
    fi
}

# Process command options
while getopts ": h" opt; do
    case $ opt in
    h) display_help
        exit 0 ;;
    \?) Display_help
        exit 1 ;;
    esac
done
shift $ (($ OPTIND - 1))

# Start execute the command
if [$ OSTYPE = 'linux-gnu']; then
    tap1 = `synclient -l | grep TapButton1 | cut -d '=' -f 2 | tr -d [: space:]`
    tap2 = `synclient -l | grep TapButton2 | cut -d '=' -f 2 | tr -d [: space:]`
    tap3 = `synclient -l | grep TapButton3 | cut -d '=' -f 2 | tr -d [: space:]`

    if [ "$ tap1" = "0"] && [ "$ tap2" = "0"] && [ "$ tap3" = "0"]; then
    enable_tapbutton.sh
    else
    disable_tapbutton.sh
    fi
    
    exit 0
fi

echo "$ warning_prefix Operating system or host name is not supported!"

 

 

#! / Bin / bash

script_name = "enable_tapbutton.sh"
script_usage = $ (cat << EOF
$ Script_name
EOF
)
script_function = $ (cat << EOF
This script is used to enable the finger tap function of Synaptics touchpad.
EOF
)
script_doc = $ (cat << EOF
-h Display this help.
EOF
)
script_examples = $ (cat << EOF
EOF
)
state_prefix = "==="
warning_prefix = "***"
error_prefix = "!!!"

function display_help () {
    if [-n "$ script_usage"]; then
    echo -e "Usage: $ script_usage"
    fi
    
    if [-n "$ script_function"]; then
    echo -e "$ script_function"
    fi
    
    if [-n "$ script_doc"]; then
    echo -e "\ n $ script_doc"
    fi
    
    if [-n "$ script_examples"]; then
    echo -e "\ nExamples"
    echo -e "$ script_examples"
    fi
}

# Process command options
while getopts ": h" opt; do
    case $ opt in
    h) display_help
        exit 0 ;;
    \?) Display_help
        exit 1 ;;
    esac
done
shift $ (($ OPTIND - 1))

# Start execute the command
if [$ OSTYPE = 'linux-gnu']; then
    synclient TapButton1 = 3
    synclient TapButton2 = 1
    synclient TapButton3 = 2
    echo "$ state_prefix Finger tapping on touchpad has been enabled!"

    exit 0
fi

echo "$ warning_prefix Operating system or host name is not supported!"

6. The window with the desktop operating functions and shortcuts: Some of these features are Sawfish comes directly binding to the Settings dialog window.
• Win + e: Displays the current window information, including name, size, location, group number

;; Display window position and dimension
(Defun display-window-paras ()
  "Display the position, dimension and group ID of the current window."
  (Interactive)
  (Let * ((cur-win (input-focus))
  (Win-width (car (window-dimensions cur-win)))
  (Win-height (cdr (window-dimensions cur-win)))
  (Win-x (car (window-position cur-win)))
  (Win-y (cdr (window-position cur-win))))
    (Display-message
    (Concat "Name:" (window-name cur-win) "\ n"
      "Dimension:" (number-> string win-width) "x" (number-> string win-height) "\ n"
      "Position:" (number-> string win-x) "x" (number-> string win-y) "\ n"
      "Group ID:" (number-> string (window-actual-group-id cur-win)))
    alert-msg-attrib)))

(Bind-keys window-keymap
    "Super-e" `(display-window-paras))


• Win + c: the window is placed on the screen (Screen) center. Which calls the current-head-dimension and current-head-offset, it is possible to support multiple monitors.

;; Center to screen
(Defun center-to-screen (cur-win)
  "Center the current window to the current screen"
  (Interactive "% f")
  (Let * ((screen-width (car (current-head-dimensions cur-win)))
  (Screen-height (cdr (current-head-dimensions cur-win)))
  (Screen-x (car (current-head-offset cur-win)))
  (Screen-y (cdr (current-head-offset cur-win)))
  (Win-width (car (window-dimensions cur-win)))
  (Win-height (cdr (window-dimensions cur-win)))
  (Win-x (car (window-position cur-win)))
  (Win-y (cdr (window-position cur-win))))
    ;; Adjust x position
    (If (> = win-width screen-width)
 (Setq win-x screen-x)
      (Setq win-x (round (+ (/ (- screen-width win-width) 2) screen-x))))
    
    ;; Adjust y position
    (If (> = win-height screen-height)
 (Setq win-y screen-y)
      (Setq win-y (round (+ (/ (- screen-height win-height) 2) screen-y))))

    ;; Modify window position
    (Move-window-to cur-win win-x win-y)))


• Win + f: show and hide the window border. Some movies can be seen on the hacker used a computer program without a window border.

 

;; Toggle window type between default and unframed
(Defun toggle-window-frame (cur-win)
  "Toggle window type between default and unframed"
  (Interactive)
  (If (= (window-type cur-win) 'unframed)
      (Set-window-type cur-win 'default)
    (Set-window-type cur-win 'unframed)))

(Bind-keys window-keymap
    "Super-f" `(toggle-window-frame (input-focus)))


• Win + Ctrl + 1 ~ 9: Adding a window to the specified group, it's like playing interstellar fleet.

;; Window group related functions
(Bind-keys window-keymap
    "Super-C-1" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 1)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-2" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 2)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-3" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 3)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-4" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 4)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-5" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 5)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-6" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 6)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-7" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 7)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-8" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 8)) alert-msg-time alert-msg-attrib))))

(Bind-keys window-keymap
    "Super-C-9" `(progn
    (Let ((cur-win (input-focus)))
    (Add-window-to-group cur-win 1)
    (Display-close-message (concat "Window" (window-name (input-focus)) "added to group" (number-> string 9)) alert-msg-time alert-msg-attrib))))


• Win + i: Minimize window

(Defun iconify-current-group (cur-win)
  "Iconify current window group"
  (Interactive "% f")
  (Iconify-group cur-win))

Win + m: toggle between maximized and the size of the current window
Win + Shift + v: the window in the vertical direction to enlarge
Win + Shift + h: window in the horizontal direction to enlarge
Win + k: kill the current window
Win + t: window lift switch between one layer and fall
Win + d: Show Desktop
Win + s: toggle between normal window and hide state. The so-called window contents hidden away soon, leaving only the title bar
Ctrl + Alt + left, right, up, down: switch between four desktops
Win + left, right, up, down: Let the current window to move in different directions until it hits the screen border or another window border
Win + w: show all desktop menu
Win + SPC: Displays the current menu window
Win + r: Display Sawfish desktop right-click menu
Win + a: Display System Menu
Win + TAB: Cycle between windows
Win + Ctrl + TAB: reverse cycle between windows
Win + l: display window list menu
Win + `: Executive function Sawfish
Ctrl + Alt + r: restart Sawfish
Ctrl + Alt + q: quit Sawfish
7. Display Laptop Battery Information: Call the acpi command, the shortcut key is Win + b, the following code:

;; Display batter information by calling acpi
(Defun display-batter-info ()
  "Display batter information by calling acpi"
  (Interactive)
  (Let * ((res-stream (make-string-output-stream))
  (Proc (make-process res-stream))
  (Res-str))
    (Call-process proc nil "acpi" "-i" "-b")
    (Setq res-str (get-output-stream-string res-stream))
    (Display-message res-str alert-msg-attrib)))

(Bind-keys global-keymap
    "Super-b" `(display-batter-info))

8. Add the window hook (before-add-window-hook) to match the criteria, assigned a special window properties such as cycle so that it does not appear in the list window, since the start kept maximized, specify the initial window size, window fixed display a location on the desktop. We need to use regular expression matching string module rep.regexp and sawfish.wm.commands.groups sawfish.wm.frames module and get the window properties. Related configuration is as follows:

(Require 'rep.regexp)
(Require 'sawfish.wm.commands.groups)
(Require 'sawfish.wm.frames)

(Defun get-wm-window-type (win)
  "Get the _NET_WM_WINDOW_TYPE property of a window"
  (Interactive)
  (Aref (nth 2 (get-x-property win '_NET_WM_WINDOW_TYPE)) 0))

(Defun get-wm-property (win prop)
  "Get the x window property of a window"
  (Interactive)
  (Nth 2 (get-x-property win prop)))

;; Set LibreOffice Impress window property
;; Remove window frame of LibreOffice Impress window when it is in fullscreen
;; Presentation.
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (and (string-match "^ soffice" (get-wm-property w 'WM_CLASS)) (= (get-wm-window-type w)' _NET_WM_WINDOW_TYPE_NORMAL))
  (Set-window-type w 'unframed)))
  t)

;; Set FreeRDP window property
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (string-match "^ FreeRDP" (get-wm-property w 'WM_NAME))
  (Progn
    (Set-window-type w 'unframed))))
  t)

;; Set xclock window property
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (string-match "^ xclock $" (get-wm-property w 'WM_NAME))
  (Progn
    (Mark-window-as-dock w)
    (Window-put w 'task-list-skip t)
    (Set-window-type w 'unframed))))
  t)

;; Set Audacious window property
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (string-match "[aA] udacious" (get-wm-property w 'WM_NAME))
  (Progn
    (Mark-window-as-desktop w)
    (Window-put w 'task-list-skip t))))
  t)

;; Set Workrave window property
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (and (string-match "[wW] orkrave" (get-wm-property w 'WM_CLASS)) (string-match "[wW] orkrave" (get-wm-property w' WM_NAME)))
  (Progn
    (Mark-window-as-dock w)
    (Window-put w 'task-list-skip t))))
  t)

;; Set full-window online video window property (played in Iceweasel)
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (string-match "plugin-container" (get-wm-property w 'WM_NAME))
  (Progn
    (Maximize-window-fullscreen w)))))

;; Set Wesnoth full-window property
(Add-hook 'before-add-window-hook
  (Lambda (w)
    (If (string-match "The Battle for Wesnoth" (get-wm-property w 'WM_NAME))
  (Progn
    (Set-window-type w 'unframed)
    (Move-window-to w 1280 0)))))

to sum up

Can be seen from this paper, by combining the GNU / Linux under different tools, such as startx, Sawfish, xmodmap, amixer etc., it can save system resources, efficient and convenient desktop operating environment.
     
         
         
         
  More:      
 
- Introduction and bash history command to quickly call (Linux)
- Will Laravel become the most successful PHP framework? (Programming)
- MySQL Error Code Complete (Database)
- Linux ./configure --prefix command (Linux)
- Access clipboard content across multiple vim instances in a terminal (Linux)
- Ubuntu font settings: Using Windows Font (Linux)
- Linux, Google Test (GTest) test environment to build step (Linux)
- Linux file permissions bit forced bits and adventure Comments (Linux)
- Linux centralized log server rsyslog (Server)
- Linux, see picture not resolve the problem (Linux)
- Java method to read and write files summary (Programming)
- Linux Network Programming - raw socket instance: MAC header message analysis (Programming)
- Linux / UNIX: Use the dd command to create a 1GB size binary (Linux)
- How to update the Linux kernel to improve system performance (Linux)
- Linux Services Comments (Linux)
- Java data structures - the linear form of the single-chain applications (Programming)
- Node.js v4.0.0 installation configuration on Ubuntu 14.04 / 15.04 (Linux)
- A detailed introduction to the Hadoop ecosystem (Server)
- CentOS / Linux restart active NIC connection paths / network configure error Error Resolution (Linux)
- MySQL rollback insert statement causes ibd file grows double (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.