Wednesday, April 30, 2014

Fixing Netbeans font problem in Linux

Netbeans shows really awful fonts when you run it on Linux based systems. The reason behind is not actually Linux itself. It's the default arguments used to invoke the Java stuff that Netbeans uses. It, by default, never invokes Anti Aliasing. Thus for, the ugly fonts. Time to fix this. Source [ https://thomashunter.name/blog/enabling-anti-aliasing-in-the-netbeans-editor/ ]

ATTENTION: The following method will always start Netbeans with Anti aliasing on. If you want otherwise, you should try using the extra arguments with the command you use to invoke Netbeans.

1. First locate 'netbeans.conf'. I did that using the command
locate netbeans.conf
But, it usually is found in the directory
/usr/local/netbeans-[version]/etc/netbeans.conf

2. Open the file and look for the line
netbeans_default_options=

3. Between the quotes, you'll see some Java related arguments. What you have to do is, make the line look like this
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m
-J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true
-J-Dsun.java2d.noddraw=true -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on"

Sunday, April 27, 2014

Changing date and time in Crunchbang Linux using Terminal

It sometimes is really handy when you don't want to waste your time searching for the 'option' or interface that will allow you to change the time of your PC. Source [ http://debmintux.wordpress.com/2010/03/29/crunchbang-set-the-time-via-terminal-cli/ ]
Set the date:
sudo date --set 2010-01-28

Set the time:
sudo date --set 21:08:00

I didn't have to do this but just in case
Restart Tint2 to see the correct time:
sudo killall tint2
tint2 &

Monday, April 21, 2014

Saving power on your Debian setup

For the last 2/3 days I'm on #! (CrunchBang Linux). The only real complain I have had is "Battery!". Fortunately enough, I found a script on the Crunchbang Forums here [http://crunchbanglinux.org/forums/viewtopic.php?id=11954] that solves the issue.
CAUTION: Please check if the files that are beings used by the script, do exist.
Copy the script and put it into /etc/pm/power.d/powersave and make it executable using
chmod +x /etc/pm/power.d/powersave
The script is:
#!/bin/sh
# A script to enable laptop power saving features for #! & Debian GNU+linux.
# http://crunchbanglinux.org/forums/topic/11954

# List of modules to unload, space seperated. Edit depending on your hardware and preferences.
modlist="uvcvideo"
# Bus list for runtime pm. Probably shouldn't touch this.
buslist="pci spi i2c"

case "$1" in
    true)
    # Enable some power saving settings while on battery
       # Enable laptop mode
        echo 5 > /proc/sys/vm/laptop_mode
       # Less VM disk activity. Suggested by powertop
        echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
       # Intel power saving
        echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
        echo 1 > /sys/module/snd_hda_intel/parameters/power_save
       # Set backlight brightness to 50%
        echo 5 > /sys/devices/virtual/backlight/acpi_video0/brightness
       # USB powersaving
        for i in /sys/bus/usb/devices/*/power/autosuspend; do
            echo 1 > $i
        done
       # SATA power saving
        for i in /sys/class/scsi_host/host*/link_power_management_policy; do
            echo min_power > $i
        done
       # Disable hardware modules to save power
        for mod in $modlist; do
            grep $mod /proc/modules >/dev/null || continue
            modprobe -r $mod 2>/dev/null
        done
       # Enable runtime power management. Suggested by powertop.
        for bus in $buslist; do
            for i in /sys/bus/$bus/devices/*/power/control; do
                echo auto > $i
            done
        done
    ;;
    false)
       #Return settings to default on AC power
        echo 0 > /proc/sys/vm/laptop_mode
        echo 500 > /proc/sys/vm/dirty_writeback_centisecs
        echo N > /sys/module/snd_hda_intel/parameters/power_save_controller
        echo 0 > /sys/module/snd_hda_intel/parameters/power_save
        echo 10 > /sys/devices/virtual/backlight/acpi_video0/brightness
        for i in /sys/bus/usb/devices/*/power/autosuspend; do
            echo 2 > $i
        done
        for i in /sys/class/scsi_host/host*/link_power_management_policy
            do echo max_performance > $i
        done
        for mod in $modlist; do
            if ! lsmod | grep $mod; then
                modprobe $mod 2>/dev/null
            fi
        done
        for bus in $buslist; do
            for i in /sys/bus/$bus/devices/*/power/control; do
                echo on > $i
            done
        done
    ;;
esac

exit 0

Saturday, April 19, 2014

Vim clipboard copy paste workaround

I love Vim. But the somewhat difficult to handle system clipboard integration just doesn't seem to fit in with me. I made a recompile to get +xterm-clipbard option, but the whole Ctrl-C Ctrl-V thing was missig. And I didn't want to recompile everytime. Got a nice workaround using xclip :) here [ http://vim.wikia.com/wiki/In_line_copy_and_paste_to_system_clipboard ]
Just to make a note / backup, here's what you have to do. Just put that into your .vimrc
" Copy paste from clipboard
vmap  y: call system("xclip -i -selection clipboard", getreg("\""))
nmap  :call setreg("\"",system("xclip -o -selection clipboard"))p
You're good to go.

Friday, April 18, 2014

Copying text from GNU screen to clipboard

GNU Screen is a great tool for command line junkies, who have declared war against the useless device called 'Mouse'. But, it has a learning curve. I was looking for a way to copy text from my terminal to the system clipboard and a great SO answer helped me [ http://stackoverflow.com/a/16286619 ].

Here's the summary
Copy text from your screen session into GNU screen's copy buffer.
Run this command within screen: cat | xsel -b
Dump screen's copy buffer to STDIN: Ctrl+a+]
Send an EOF to cat to terminate it: Ctrl+d

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...