PDA

View Full Version : Linux Tips and Tricks



banderlog
08-10-2013, 01:40 PM
Hello. I suggest to make one topic for all Linux tips. So it could be like a knoweldge base for Asus ROG users.

And I'll start with my own experience and found solutions.

So. Now I'm using Xubuntu 13.04. I've tried Unity, Cinnamon, KDE, but stopped at XFCE, because on my Asus G75VX with GeForce GTX 670MX only on XFCE I could get absolutely tear-free experience.

If you don't know what "tearing" is, then just imagine, that when you move windows or watching a movie your screen tears apart. Or you can read about it here (http://en.wikipedia.org/wiki/Screen_tearing).

Fix for tearing in XFCE

So, from start on a clean install I had this tearing with compositing either on or off. That's what I've done:

1. First of all turn off XFCE compositing in settings. You'll find it in Xfce 4 Settings Manager -> Windows Manager Tweaks -> Compositor tab. Uncheck "Enable display compositing".

2. Then install another compositor - Compton. On Ubuntu based distros open terminal and copy-paste:

sudo add-apt-repository ppa:richardgv/compton && sudo apt-get update && sudo apt-get install compton

3. Before runnig Compon you must create config. I took one from Archlinux Wiki and changed there couple things. Everything there is commented, so you can play with it.


# Shadow
shadow = true; # Enabled client-side shadows on windows.
no-dock-shadow = true; # Avoid drawing shadows on dock/panel windows.
no-dnd-shadow = true; # Don't draw shadows on DND windows.
clear-shadow = true; # Zero the part of the shadow's mask behind the
# window. Fix some weirdness with ARGB windows.
shadow-radius = 7; # The blur radius for shadows. (default 12)
shadow-offset-x = -7; # The left offset for shadows. (default -15)
shadow-offset-y = -7; # The top offset for shadows. (default -15)
# shadow-opacity = 0.7; # The translucency for shadows. (default .75)
# shadow-red = 0.0; # Red color value of shadow. (0.0 - 1.0, defaults to 0)
# shadow-green = 0.0; # Green color value of shadow. (0.0 - 1.0, defaults to 0)
# shadow-blue = 0.0; # Blue color value of shadow. (0.0 - 1.0, defaults to 0)
shadow-exclude = [ "n:e:Notification", "n:e:Docky", "g:e:Synapse", "g:e:Conky", "n:w:*Firefox*", "n:w:*Chromium*", "class_g ?= 'Cairo-dock'", "class_g ?= 'Xfce4-notifyd'", "class_g ?= 'Xfce4-power-manager'"]; # Exclude conditions for shadows.
# shadow-exclude = "n:e:Notification";
shadow-ignore-shaped = true; # Avoid drawing shadow on all shaped windows
# (see also: --detect-rounded-corners)

# Opacity
# menu-opacity = 0.9; # The opacity for menus. (default 1.0)
# inactive-opacity = 0.9; # Default opacity of inactive windows. (0.0 - 1.0)
# active-opacity = 0.8; # Default opacity for active windows. (0.0 - 1.0)
# frame-opacity = 0.8; # Opacity of window titlebars and borders. (0.1 - 1.0)
# inactive-opacity-override = true; # Let inactive opacity set by 'inactive-opacity' overrides
# value of _NET_WM_OPACITY. Bad choice.
#alpha-step = 0.06; # XRender backend: Step size for alpha pictures. Increasing
# it may result in less X resource usage,
# Yet fading may look bad.
# inactive-dim = 0.2; # Dim inactive windows. (0.0 - 1.0)
# inactive-dim-fixed = true; # Do not let dimness adjust based on window opacity.
#blur-background = true; # Blur background of transparent windows.
# Bad performance with X Render backend.
# GLX backend is preferred.
#blur-background-frame = true; # Blur background of opaque windows with transparent
# frames as well.
#blur-background-fixed = false; # Do not let blur radius adjust based on window opacity.
#blur-background-exclude = [ "window_type = 'dock'", "window_type = 'desktop'" ];
# Exclude conditions for background blur.

# Fading
fading = true; # Fade windows during opacity changes.
fade-delta = 4; # The time between steps in a fade in milliseconds. (default 10).
fade-in-step = 0.02; # Opacity change between steps while fading in. (default 0.028).
fade-out-step = 0.02; # Opacity change between steps while fading out. (default 0.03).
# no-fading-openclose = true; # Avoid fade windows in/out when opening/closing.
fade-exclude = [ ]; # Exclude conditions for fading.

# Other
backend = "glx" # Backend to use: "xrender" or "glx". GLX backend is typically
# much faster but depends on a sane driver.
#mark-wmwin-focused = true; # Try to detect WM windows and mark them as active.
#mark-ovredir-focused = true; # Mark all non-WM but override-redirect windows active (e.g. menus).
#use-ewmh-active-win = false; # Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused
# instead of using FocusIn/Out events. Usually more reliable but
# depends on a EWMH-compliant WM.
#detect-rounded-corners = true; # Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on.
#detect-client-opacity = true; # Detect _NET_WM_OPACITY on client windows, useful for window
# managers not passing _NET_WM_OPACITY of client windows to frame
# windows.
#refresh-rate = 0; # For --sw-opti: Specify refresh rate of the screen. 0 for auto.
vsync = "opengl-swc"; # "none", "drm", "opengl", "opengl-oml", "opengl-swc", "opengl-mswc"
# See man page for more details.
#dbe = false; # Enable DBE painting mode. Rarely needed.
paint-on-overlay = true; # Painting on X Composite overlay window. Recommended.
#sw-opti = false; # Limit compton to repaint at most once every 1 / refresh_rate.
# Incompatible with certain VSync methods.
unredir-if-possible = true; # Unredirect all windows if a full-screen opaque window is
# detected, to maximize performance for full-screen windows.
focus-exclude = [ ]; # A list of conditions of windows that should always be considered
# focused.
detect-transient = true; # Use WM_TRANSIENT_FOR to group windows, and consider windows in
# the same group focused at the same time.
detect-client-leader = true; # Use WM_CLIENT_LEADER to group windows.
invert-color-include = [ ]; # Conditions for windows to be painted with inverted color.

# GLX backend # GLX backend fine-tune options. See man page for more info.
glx-no-stencil = true; # Recommended.
#glx-copy-from-front = false; # Useful with --glx-swap-method,
# glx-use-copysubbuffermesa = true; # Recommended if it works. Breaks VSync.
# glx-no-rebind-pixmap = true; # Recommended if it works.
#glx-swap-method = "undefined"; # See man page.

# Window type settings
wintypes:
{
tooltip = { fade = true; shadow = false; opacity = 0.75; focus = true; };
# fade: Fade the particular type of windows.
# shadow: Give those windows shadow
# opacity: Default opacity for the type of windows.
# focus: Whether to always consider windows of this type focused.
};

Copy it and save. I saved it in ~/.compton.conf.

4. Now you just start it with this command:

compton --config ~/.compton.conf -b

5. If everything is fine you can make an executable and place it to autostart. I store my scripts in ~/.scripts/. So just create a file ~/.scripts/compton.sh and copy-paste there:

compton --config ~/.compton.conf -b

Don't forget to change location of config file to where you saved it.

Then in terminal:

chmod +x ~/.scripts/compton.sh

to make it executable.

6. Place it to autostart in Xfce 4 Settings Manager -> Session and Startup.

Now it's blazing fast and furious. Much faster then Ubuntu or Windows 7-8. You can notice it when you scroll heavy sites in browser or playing games.

P.S. If you use Compiz, you can get rid of tearing by increasing your refresh rate to 60 or 120 in settings (CompizConfig Setting Manager), but in Ubuntu 13.04 it resets to default 50 after each reboot. And even after doing it sometimes you can see tearing, and it's much heavier on hardware.

banderlog
08-10-2013, 01:46 PM
Again for Xubuntu 13.04 and Asus G75VX with GeForce GTX 670MX.

Next problem is not functioning Fn keys.

Fn keys

On Ubuntu, Kubuntu and Linux Mint all Fn keys work, even brightness controls start to work after suspending and waking up laptop, but not in Xubuntu. I've searched for solutions and came for simpliest for me. Maybe in next versions everything will work out of the box. Xubuntu 13.10 with Mir, for example, doesn't give tearings. But for now...

Fn+F9 for Touchpad

Touchpad is "SynPS/2 Synaptics TouchPad.

1. Create script for switching its state:

nano ~/.scripts/asus-touchpad.sh

Copy-paste these lines, which I've found here (http://ubuntuforums.org/showthread.php?t=1744106):


#!/bin/bash
#
# list of synaptics device properties http://www.x.org/archive/X11R7.5/doc/man/man4/synaptics.4.html#sect4
# list current synaptics device properties: xinput list-props '"SynPS/2 Synaptics TouchPad"'
#
if xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | grep 0
then
xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 1
else
xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 0
fi
exit

Then make it executable:

chmod +x ~/.scripts/asus-touchpad.sh

And make a hotkey in Settings Manager for this file on Fn+F9.


Fn+F5 and Fn+F6 for screen backlight

I've just installed xbacklight:

sudo apt-get install xbacklight

Then made hotkeys on Win+F5 and Win+F6 for "xbacklight -10" and "xbacklight +10".

I used Win key instead of Fn, because Fn+F5 and Fn+F6 don't give any output on acpi_listen and just don't work.

Fn+F3 and Fn+F4 for keyboard backlight

I've tried some solutions from internet, but they didn't help. So I've wrote teo scripts:

nano ~/.scripts/leds_down.sh


#!/bin/bash
brightness=$(cat "/sys/class/leds/asus::kbd_backlight/brightness")
a=$((brightness-1))

if [ "$brightness" -gt 0 ]
then
echo $a >> /sys/class/leds/asus\:\:kbd_backlight/brightness
fi

and

nano ~/.scripts/leds_up.sh


#!/bin/bash
brightness=$(cat "/sys/class/leds/asus::kbd_backlight/brightness")
a=$((brightness+1))

if [ "$brightness" -lt 3 ]
then
echo $a >> /sys/class/leds/asus\:\:kbd_backlight/brightness
fi

Then made them executable:

chmod +x ~/.scripts/leds_up.sh
chmod +x ~/.scripts/leds_up.sh

Then add one string to rc.local to give all users permission to change file "/sys/class/leds/asus::kbd_backlight/brightness" on every boot:

sudo nano /etc/rc.local

and paste there:

chmod 666 /sys/class/leds/asus\:\:kbd_backlight/brightness

BEFORE "exit 0". So it looks like:


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

chmod 666 /sys/class/leds/asus\:\:kbd_backlight/brightness
exit 0


And now just make shortkeys on Fn+F3 and Fn+F4 for ~/.scripts/leds_down.sh and ~/.scripts/leds_up.sh.

Now you can reboot or execute in terminal sudo chmod 666 /sys/class/leds/asus\:\:kbd_backlight/brightness.

banderlog
08-10-2013, 01:47 PM
Hybernation

For turning on hybernation I found solution here. (http://www.linuxandlife.com/2012/06/how-to-enable-hibernation-in-linux-mint.html)

You just create file with:

sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

and copy-paste there:


[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

After reboot hybernation works. Don't know what for, if XFCEs cold start is faster, then waking up from hybernation. :) And don't forget, that you need swap equal or greater than your memory.

banderlog
08-10-2013, 02:04 PM
PulseAudio Fix

Edit pulseaudio config:

sudo nano /etc/pulse/default.pa

Find there line:

load-module module-udev-detect use_ucm=0

and add tsched=0 to that line, so now it looks like:

load-module module-udev-detect use_ucm=0 tsched=0

Next edit daemon.conf:

sudo nano /etc/pulse/demon.conf

and find there line "; default-sample-rate = 48000", uncomment it, so it looks like:

default-sample-rate = 48000

After reboot sound will be clean and pleasant. Also if you use audio player with some resampler plug-in, turn resampler on, change it to best quality and to 48000Hz.

Warning! After these fixes music will cause orgasms in your ears.

banderlog
08-10-2013, 02:06 PM
Video players

For VLC go to settings -> Video and change output to OpenGL GLX (XCB).

In other players also use OpenGL for output.

banderlog
08-10-2013, 02:13 PM
Battery life

To dramaticaly increase your notebooks' lifetime just do:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update && sudo apt-get install tlp tlp-rdw smartmontools ethtool
sudo tlp start

On Asus G75VX it gives longer lifetime on battery and cooler temperatures of CPU and VGA.

Also you can install "preload". If you use general HDDs it will give you a feeling like you're using SSHD.

sudo apt-get install preload