Friday, October 16, 2020

Setting up Pi-hole as a recursive DNS server

 It's been a couple months since I set up an intel nuc computer as a network wide ad blocker using pi-hole software and it's been working great.  Internet speed is increased and the amount of internet queries blocked is around 15-20%.  There have been a couple of sites that I had to whitelist to get the app to work especially ad sponsered movie apps, but relatively few issues overall.

Being privacy minded, and trying out a few of the upstream dns servers and reading their privacy policies led me to question can any free dns servers really be trusted?  Although I am not going to dark web web-sites, I don't like the idea of big corporations tracking everything done online. One way they can use this data is to track your political views by what news web sites you go to. The algorithm then labels you as conservative or liberal, etc.

This got me to look into using my pi-hole server as a complete dns server solution, thereby eliminating the need for another dns server.  Turns out the pi-hole team had already thought of this and had written a procedure for setting up a recursive dns server using the same hardware as your ad-blocker.

Following this procedure https://docs.pi-hole.net/guides/unbound/  I was able to configure my pi-hole to be my full dns server solution.  It was fairly easy to configure and setup by installing "unbound" and copying the example pi-hole.conf file to "/etc/unbound/unbound.conf.d/pi-hole.conf" on my nuc computer.  After installation it just took rebooting the pi-hole server and configuring the IPV4 address in the pi-hole admin dashboard. Checking that your recursive DNS server is working properly can be done by going to https://dnsleaktest.com/ and running the extended test.  Its been a few weeks since I set this up and have had no issues and no noticable reduction in speed to access web sites.  

Overall, I'm completely satisfied with this solution and thankful that the pi-hole team and the "unbound" software developers have made it so easy to setup for those that might not attempt to do it otherwise.

Friday, August 14, 2020

Setting up a Pi-hole Ad blocking dns server

 Awhile back I came across this site https://pi-hole.net/   It was interesting to have a network wide ad blocker over having multiple ad blocking plugins on different browsers on different computers.  After some reading about it, I discovered it would also block ads on phones and in-app ads.  That made it more appealing since in my household we have 6 active computers, 4 phones, and 3 tablets.  To get the same kind of ad blocking I would need to install ad blockers on all the devices and even then the blocking would not be as effective as Pi-hole. It also speeds up your browsing by reducing downloaded ads and using a dns cache for frequent sites.

Pi-hole works by becoming your dns server for all the devices connected to your router.  It uses built-in ad blocking lists that can be updated and added to. After installation there is web based dashboard http://pi.hole/admin/ that shows all the addresses blocked and allows configuration of whitelists, blacklists, and all sorts of options.  During install you have the option of choosing between several free public dns servers to use as your internet dns. The choices are google, opendns, level3, comodo, dns.watch, quad9, cloudflare, or custom.  I tested a few of these and settled on quad9 for speed and consistency. It also blocks malicious sites which is nice if you have kids. After install you just need to configure your router to use your new pi-hole server for all DNS records.

First you must select the hardware you want to use.  The cheapest route is to use a raspberry pi.  I have an original raspberry pi B that met the minimum specs but I made a robot car out of it and so my choice was to use other hardware.  The sweet thing is this will run on any hardware that supports linux.  I had an intel nuc that was just collecting dust so decided to use it.  The installation was straight forward, download and install the linux distribution of your choice, it supports Ubuntu, Fedora, CentOS, Debian, and Raspberry piOS. In my case I downloaded ubuntu and used the dd command make a bootable usb stick and installed it onto my nuc. 

To install the pi-hole software, boot up your linux server and access a terminal or command prompt and type:

curl -sSL https://install.pi-hole.net | bash 

During the installation there are prompts for some information such as ip address to use for the new server and the public dns server to use.  This guide can help give more information if needed: https://www.smarthomebeginner.com/pi-hole-setup-guide/#Step_4_Pi_Hole_Installation

After install reboot your pi-hole and configure your router's dns server settings with the ip address of the pi-hole server that you assigned (i.e. 192.168.1.4) for ipv4. ipv6 can be configured with the address provided on the last installation screen.  Thats it! even though it seems complicated it literally took ten minutes once linux was installed to finish.  

The pi-hole dashboard will show when a new version of the pi-hole software is available.  To upgrade simply access your pi-hole server terminal and type: pihole -up

I've been enjoying all the stats and information on the dashboard and love to see all the blocked domains.  Enjoy! 

 

Monday, July 13, 2020

Changing default protocol to IPV4 vs IPV6 in Linux

Even though IPv6 is default on most systems now and has been for a number of years, it still seems to be more problematic than using IPV4.  It is interesting that a new router I bought had IPV6 disabled by default and the settings buried for turning it on.  That is why I prefer to have my web browser default to ipv4 first with the fallback to ipv6 within a second.

To configure this on Linux edit the /etc/gai.conf file using root priviledges, scroll down to where you see the following text and uncomment the precedence line.  Save the file and reboot.

#    For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96  100

To test that its working properly go to https://ipv6-test.com/

It will show the default protocol and the fallback to ipv6 time.  The score should be 14/20 typically.

Thats it, now using a more proven and reliable protocol first with the newer and less proven protocol as backup.

Sunday, February 02, 2020

keyboard and mouse update

Another aspect of having a great computer system is the peripherals one chooses.  Specifically the mouse and keyboard.  I prefer mechanical keyboards to membrane ones.  Mechanical keyboards have several benefits over membrane keyboards, they are faster by registering when multiple keys are pressed at the same time (n-key rollover), last longer up to 70 million key presses, and the keys have a more tactile feel.  You can also replace keycaps and customize buttons or lighting on most mechanical keyboards.    If you are unsure of what type of keyboard you are using right now, its probably a membrane keyboard.  Most PC manufacturers do not include mechanical keyboards with their systems since they are more costly.
Probably the greatest keyboard ever made was the IBM M series keyboard M series.   This keyboard used a buckling spring design that offered tactile feedback with the side effect of being quite noisy.  If you can live with the noise some people love this keyboard and you can still get a clone of it here Unicorp
I like the feel of the M series keyboard but it is a bit noisy for my taste.   My favorite keyboard that I own is a Corair K63 which uses cherry red switches.   Cherry switches are made in germany and considered the best switches for mechanical keyboards cherry switches. They come in red (light) brown (medium) blue (tactile) black (heavy) and a few other colors and activation force.   I love cherry reds, light and fast.  The only drawback to the Corsair K63 is that because it has unique media keys it would sometimes cause linux to hang at boot.   This was enough of an annoyance for me to look for a new mechanical keyboard that would work well in linux.  That led me to the logitech romer-g keyboards.   Since Corsair has an exclusive contract with cherry, logitech had no choice but to find another source for their switches.  They chose a company called Omron which makes high quality mouse switches Omron switches.  The swiches logitech designed with omron puts the led in the center of the switch opposed to the top edge in cherry switches.  They also claim 70 millon key presses opposed to cherrys 50 million.   After some research i ended up buying a Logitech keyboard with Omron Romer-G swtiches and I must say I have been completely satisfied with the lighting, tactile feedback, and speed of the keys logitech g413.   I also like how it has a usb port in the keyboard to plug in a usb stick or other devices.

As a seperate purchase I was looking for a new mouse that would be comfortable and fast with customizable lighting and buttons.  I saw a nice no-name chinese gaming mouse on amazon.com and decided to give it a try.  Although it wasn't too bad, it felt cheap and didn't fit my hand well causing hand fatigue while using it for extended periods.  I decided to keep searching for a better mouse, and ended up finding this one pro mouse
And while it looks simple it has a very fast sensor and programmable buttons and lighting.  I made the forward button the windows key, and the resolution button a page down button for faster shortcut keys and web use.  The lighting options allow changing colors, intensity, and patterns.   Another nice thing about this mouse is that the button and lighting customizations can be saved to internal memory in the mouse, so that you can use it in other OS's or plug into other computers and keep your settings without additional softare needed.

Overall I believe the a mouse and keyboard are the items that you tend to interact with more often than any other part of a PC and it is very important to get the right components.  Cheap items tend to be that...cheap.  Paying for higher quality components offer more features and tend to last longer which may not make them more expensive in the long run.  

Tuesday, January 14, 2020

Time to refresh a pc

I put together a pc back in 2014 that was a small ITX build.  I picked all the components which were pretty high-end at that time.  Gigabyte Z97N motherboard, I5-4690 3.5ghz CPU, Nvidia GTX970 GPU, 8G ram, Samsung 256G SSD, and slot DVD-RW drive.   It's been a good reliable pc however one thing always bothered me.  I had picked a new case from eVGA called the Hadron Air shown here: Hadron Air  I thought it looked good and was a very small case with a built in 80plus gold power supply.  What I didn't know at the time was that it is a 1U size server type power supply like this: 1U power supply.  This is probably a good reliable power supply but since it's made to be in a noisy server room its not good for a pc that is near your ears.  This power supply puts out a high pitch whine due to the tiny fan it uses.  Most times I could ignore it but sometimes it just bothered me like having ringing in my ears.

I did some research and the consensus was there is no quiet 1U power supply unless its low wattage, and since I couldn't fit a regular ATX power supply into the Hadron Air case I had no other choice but to replace the case.

After some research I decided on this case from Thermaltake: ITX Case.  One thing that sold me was the large 200mm fan which is slower moving making it very quiet and the dust filters on the input in front and on bottom.  I combined that with a super quiet 430W ATX power supply also from Thermaltake: power supply.  I decided to update my ram at the same time so I bought 16G ram from patriot: viper ram.

It only took about an hour to install the power supply and move the other components into the new case and connect/cable tie the cables.   This new case was a pleasure to work with since all four sides are removeable allowing access to anything with ease.  I then installed the new ram, and fired it up for the first time.   I was and still am amazed how quiet it is.  I had to verify the case fan and power supply fan were really working because I couldn't hear them.  The only fan noise I can hear is coming from my nvidia geforce.   I also like the layout and airflow of this case, its just an overall well designed case.

Overall, I'm happy I finally decided to do this upgrade as it makes using this pc a much more pleasent experience and I didn't want to replace the whole thing just because of noise. I also learned that size does matter, at least when it comes to fans.

Saturday, February 16, 2019

WebRTC leaks and how to fix in Firefox

WebRTC is a technology in modern web browsers that allows direct real time peer to peer communication between browsers.  This allows audio and video communication to work without needing to install plugins or download various applications.  While it has allowed sites like google hangouts to function, there are some downsides to those wanting more privacy online.

WebRTC is known to have security issues that can leak your real IP address to various web sites while using a VPN.  The purpose of having a VPN is to hide your actual location (ISP provided IP address) from any websites you visit.  This is for privacy concerns or to use services blocked in your country.  By having WebRTC enabled in your browser it may make your VPN service worthless.

There are a number of downloadable plugins that disable WebRTC.  However these also pose security concerns.  If you are using Firefox as your browser WebRTC can be turned off by using the about:config command built into Firefox.

Here is how to disable WebRTC in Firefox:

type about:config in the url box
search for media.peerconnection.enabled and set to false
search for media.navigator.enabled and set to false (disables microphone and camera information, important for laptop users since they are built-in).

to check if items are disabled, go to this site:  https://browserleaks.com/webrtc
and make sure everything is either false or n/a.

Thursday, October 18, 2018

KCMOUSE - Minimal Window Manager for X11



      I recently updated my minimal window manager for X11 that I made a couple years ago. I had stopped using it because for some reason the cpu usage was going to 100% occasionally when using one particular program. I decided to look at the code again and discovered the issue. It was because a window was not properly raised to the top of the stack after calling the XCirculateSubwindowsDown and XCirculateSubwindowsUp commands. It wasn't noticable during normal use, due to the XsetInputFocus command proving focus to the new window.


     The fix was to query the mouse pointer after the window cycle to find the new focused window and add it to the focuswin variable. Then I added the XraiseWindow command to raise the newly focused window. Now all my programs are happy, and when they are happy I'm happy :} Here is a snipplet of the code I'm talking about:


XCirculateSubwindowsDown(display, root);
XQueryPointer(display, root, &unusedwin, &focuswin, &unusedint, &unusedint, &unusedint, &unusedint, &unusedint);
XSetInputFocus(display, focuswin, RevertToNone, CurrentTime);
XRaiseWindow(display, focuswin);



     I've updated the source code on Github here: https://github.com/netfun81/kcmouse


You are welcome to it Microsoft :}



Friday, October 12, 2018

Free VPN's

   One of the many anti-privacy things that have happened in recent years is that web browsers have moved beyond just detecting your IP location, which pinpoints your location to within your city, to now detecting geo location which is very accurate.  They use wifi and other means to detect your actual location. You can find sites on the web that will show you what information websites have access to.  Sites like https://ipleak.net/ will remind you of the amount of information that is collected by many websites.

   In my pursuit of limiting the amount of personal information I share with the world, it was evident that along with a safe DNS I also need a way to hide my location.  This led me to needing a vpn.  I tried many free vpns and discovered there is a reason they are free.  They typically leak your dns or sell to 3rd party companies to make money.  It was interesting to find that the biggest supporter of freevpns was Google...they really want your data :)  Luckily there are sites that check for dns leaks, for instance https://www.dnsleaktest.com/  It is easy to check how many leaks your vpn or dns is involved with.

   After many hours of searching for a free vpn that isnt bandwidth or download GB restricted, and doesnt sell my data, I turned to browser plugins.  There are several browser vpn plugins for firefox, however some want permission for viewing everything even clipboard data.  I finally settled for a plugin called Hoxx vpn proxy  https://addons.mozilla.org/en-US/firefox/addon/hoxx-vpn-proxy/?src=search   It's a easy to use and safe vpn client that has only one drawback that I can find, it requires a confirmed email address.  It does log files and it will ban you if you try to go to illegal sites.  It's not for people that want to do illegal activity, like watching pirated movies, as it will ban or report you, but it is for those that want privacy and at least make it harder for governments and others to track each site you visit to obtain your political, spiritual, purchasing history, hobbies, etc, and to obtain a complete snapshot of your online life.

   We may not be able to stop the anti-privacy train from moving quickly down the tracks, but we can try to at least drag our feet and maybe slow it down a bit :)

*UPDATE:  I wanted to find a more open source solution for a vpn client.  I finally found https://www.vpngate.net/en/.   It is an open source vpn client that uses volunteer servers from around the world to connect with.  The servers at the top of the list are usually faster or have more open connections.  You will need to have openvpn installed https://openvpn.net/ and then just download the openvpn config file and add it to your network connection manager (in my case NetworkManager, which needs the plugin "networkmanager-openvpn" installed also).   Since there are quite a few shady vpn operations out there,  I think having an open source solution with many server options is the best way to protect yourself online.  However, its still important to check out the servers you connect with using the tools I mentioned above.

Tuesday, September 12, 2017

DNS Public Servers

I know I'm only supposed to post once a year on here, but well I guess I'm feeling ambitious. :}   Today's topic is DNS servers.   I've been using Comcast as my ISP for some time, mainly because there are no other decent choices in the area I live in.  It's not horrible, however the main DNS servers are not that reliable and they don't support IPv6.   I like having IPv6 support mainly due to the fact it's impossible to know what IPv6 only sites are available if it isn't supported.   Whenever I install a new linux version one of the first things i do is go to http://ipv6-test.com/ and see if my ipv6 is working.    That is how i first noticed my ISP was not supporting IPv6.   I then searched for a public DNS server that would support IPv6.   I have been using Google's free DNS servers for a number of years now, set to dns 8.8.8.8 and secondary dns of 8.8.4.4.   It has been more reliable and faster than Comcast's DNS servers.  So what's the issue then?   The issue is really Google's relentless data collection policies.   Along with the fact they make their money primarily by selling advertising.

This led me onto a quest for a DNS server that wasn't so interesting in selling my data but might actually be interested in providing a good DNS experience.   There are  several good ones, https://www.opendns.com/ worked well but is mostly focused on DNS filtering which was not my primary reason for changing.   I then tried https://dns.watch/ which worked well and I liked they don't log or sell information but after reading an article about DNS latency, it mentioned that it is very important to find one in your country because every time you type in a url it has to go to that server to resolve the ip address.  Looking up the information on dns.watch it appears to be located in Germany.   Having a DNS server in Germany can add latency and slow down your requests.   That led me to looking for a more open-source solution.

Which led me to https://www.opennic.org/  where anyone can run their own DNS server.   I thought about doing that, all you need is a Linux server, which I could easily set up.  That would be the best solution, however they mentioned on their wiki they don't recommend running a DNS server from ones home, again its about latency.  The less hops is always better.   So instead of running my own DNS server I found one that is near that supports both ipv4 and ipv6 and does not log and supports dnscrypt.   Been using it for a couple weeks and it is fast and been awesome so far.

I doubt the average person really cares about what DNS server they use, but why make it easier for huge companies to monitor what sites you visit in order to provide you with more ads.   Of course DNS logging is only one way they collect information and certainly won't make you anonymous on the web.     It may be impossible to stay anonymous in todays' world but you don't need to hand them all your personal information on a silver platter either :}



Tuesday, July 18, 2017

Linux and SystemD

Anyone following or using Linux has noticed that the systemd init system has been pushed into more and more distributions.   Most of the popular distributions have switched to it and offer little choice of using anything else.  It was originally developed by a redhat employee and first appeared in fedora several years ago.  I have used distros that are based on systemd and it seems to work fine and does provide a faster startup.  The concern is that by standardizing the init system it allows Linux to become less fragmented (which could be good, but) and thereby easier to monitor.   I remember seeing a video analysis of the systemd documentation a couple years ago where in one area the developer had a comment "this was added to keep the 3-letter agencies happy".   The guys doing the analysis only said.. not sure what he means by that but it might be a good idea to stay far away from this.    This along with the fact that systemd is not too unix like (do one thing and do it well is the unix motto) has created some push back in the linux community and therefore this wiki page was created:
without-systemd.org

I have tried several of the distros listed on the wiki and there are two that really stand out as being more stable and tested.
manjaro-openrc and devuan.org

I originally favored manjaro because its based on Arch linux which is my favorite distribution.  However because it uses the Arch repos and the Arch Users Repository (AUR),  i noticed that some programs wanted to install systemd back in as a dependency, which defeats its purpose.

After another run with Slackware i settled on Devuan as my distro of choice.  Seems to work well, based on Debian but without systemd.  Haven't noticed any negative effects yet, and have installed quite a lot of software.   I did have to change to the testing repos instead of stable because the network driver and nvidia driver were too old in the stable repositories for my hardware.

Combine Devuan with i3 Window Manager and you end up with a pretty sweet fast OS that hopefully isn't full of spyware  :}

UPDATE:  After a few weeks on Devuan, I was disappointed that the distro is not updated regularly.  Some of the software is quite old.  Decided to go with a more bleeding edge distro Void Linux that uses runit for the init system.  Install went well and all the packages I needed were available.  Might keep this one for awhile :}


Sunday, April 10, 2016

Windows 10 and Virtual Desks

I'm happy that Microsoft finally added virtual desktops to windows.  They could have made the hotkeys customizable to make it more user friendly but then maybe I expect too much :}

Luckily there is my old friend AutoHotKey:  http://ahkscript.org/
install the program to allow launching any .ahk file or compiling it to an .exe file to run on computers that don't have AutoHotKey installed.

I made a simple script that does 3 things:

      1.  Provides a popup menu of applications and functions with the middle mouse button
      2.  Shows all the desktops when X2 (forward button on 5 button mouse) is pressed
      3.  Moves forward and backward through the desktops by holding X2 and using the mouse wheel


Heres the code, simply copy/paste to notepad and save as vdesk.ahk     It can be run by double clicking from explorer or compiled to a .exe by rightclicking the file and selecting the option.   Add to the start menu startup folder for loading at windows login. 

Menu, MyMenu, Add, Firefox
Menu, MyMenu, Add, Explorer
Menu, MyMenu, Add, CCleaner
Menu, MyMenu, Add 
Menu, MyMenu, Add, Desktop
Menu, MyMenu, Add, Programs
Menu, MyMenu, Add 
Menu, MyMenu, Add, Logoff
Menu, MyMenu, Add, Shutdown
return

Explorer:
Run, explorer.exe
Return

Firefox:
Run, C:\Program Files (x86)\Mozilla Firefox\firefox.exe
Return

CCleaner:
Run, C:\Program Files\CCleaner\ccleaner64.exe
Return

Desktop:
Run, C:\Users\Public\Desktop
Return

Programs:
Run, C:\Users\kcair\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Return

Logoff:
Shutdown, 0
Return

Shutdown:
Shutdown, 1
Return

Mbutton::Menu, MyMenu, Show

XButton2 & Wheelup::Send, ^#{Left}
XButton2 & Wheeldown::Send, ^#{Right}
XButton2::Send, #{Tab}

Tuesday, March 03, 2015

XCB Minimal Window Manager

In my quest for a good minimal window manager, I have tried almost everything available for linux, including projects on https://github.com     I havent found anything yet that works exactly as I want, but I enjoy hacking on the code to see if I can make them work more to my liking (or work at all).   This is a recent attempt to hack some public domain xcb code to meet my needs.   After my modifications it is only 134 sloc (single lines of code) and does the basic window manager functions I use.   Here is the code:

#include <stdlib.h>
#include <sys/wait.h>
#include <xcb/xcb.h>
#ifdef COMPOSITE
#include <xcb/composite.h>
#endif
int main(int argc,char**argv){
    static const uint32_t di[]={0,0,1440,900},cwa=XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT|XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY|XCB_EVENT_MASK_STRUCTURE_NOTIFY;
    xcb_connection_t*d=xcb_connect(0,0);
    void*p;
    int32_t*x,*y,*tx=0,mx,my,rt=xcb_setup_roots_iterator(xcb_get_setup(d)).data->root,cs[255],*cz=cs+1;
    uint8_t mz,mZ;
    xcb_change_window_attributes(d,rt,XCB_CW_EVENT_MASK,&cwa);
    xcb_grab_key(d,1,rt,0,133,XCB_GRAB_MODE_ASYNC,XCB_GRAB_MODE_ASYNC);
    xcb_grab_button(d,1,rt,XCB_EVENT_MASK_BUTTON_PRESS,XCB_GRAB_MODE_ASYNC,XCB_GRAB_MODE_ASYNC,XCB_NONE,XCB_NONE,XCB_GRAB_ANY,XCB_MOD_MASK_4);
    #ifdef COMPOSITE
    xcb_composite_redirect_subwindows(d,rt,XCB_COMPOSITE_REDIRECT_AUTOMATIC);
    #endif
    xcb_generic_event_t*e=0;
main:xcb_flush(d);
    waitpid(-1,0,WNOHANG);
    noflush:x=y=cz-1;
again:free(e);
    switch((e=xcb_wait_for_event(d))->response_type&127){
    case XCB_BUTTON_PRESS:
        for(;x>cs;x--)
            if(*x==((xcb_button_press_event_t*)e)->child){
                if(((xcb_key_press_event_t*)e)->detail==2)goto pocus;
            case XCB_KEY_PRESS:
                mz=128|((xcb_key_press_event_t*)e)->detail;
                my=((xcb_key_press_event_t*)e)->state;
                goto*(cz==cs+1?&&kcode:&&stack);
            }
        goto noflush;
    case XCB_KEY_RELEASE:
        if(((xcb_key_press_event_t*)e)->detail!=133||!tx)default:goto again;
        xt:x=tx;
        tx=0;
        goto stack;
    case XCB_CONFIGURE_REQUEST:;
        uint32_t c[7];
        p=c;
        for(mz=0;mz<5;mz++)
            if(((xcb_configure_request_event_t*)e)->value_mask&1<<mz){*(uint32_t*)p=*(int16_t*)(((void*)e)+16+mz*2);p+=4;}
        if(((xcb_configure_request_event_t*)e)->value_mask&XCB_CONFIG_WINDOW_SIBLING){*(uint32_t*)p=((xcb_configure_request_event_t*)e)->sibling;p+=4;}
        if(mz=((xcb_configure_request_event_t*)e)->value_mask&XCB_CONFIG_WINDOW_STACK_MODE)*(uint32_t*)p=((xcb_configure_request_event_t*)e)->stack_mode;
        xcb_configure_window(d,((xcb_configure_request_event_t*)e)->window,((xcb_configure_request_event_t*)e)->value_mask,c);
        if(mz){
            p=xcb_query_tree_reply(d,xcb_query_tree_unchecked(d,rt),0);
            int32_t*cl=p+32+((xcb_query_tree_reply_t*)p)->children_len*4;
            for(y=p+32;y<cl;y++){
                for(x=cs+1;x<cz;x++)
                    if(*x==*y)goto nono;
                *y=0;
                nono:;
            }
            x=cs;
            for(y=p+32;y<cl;y++)
                if(*y)*++x=*y;
            free(p);
            goto pocus;
        }else goto main;
    case XCB_MAP_REQUEST:
        p=xcb_get_window_attributes_reply(d,xcb_get_window_attributes_unchecked(d,((xcb_map_request_event_t*)e)->window),0);
        if(((xcb_get_window_attributes_reply_t*)p)->override_redirect)goto freeflush;
        free(p);
        for(;x>cs;x--)
            if(*x==((xcb_map_request_event_t*)e)->window)goto noflush;
        xcb_map_window(d,*cz++=((xcb_map_request_event_t*)e)->window);
        goto hocus;
    if(0)case XCB_MOTION_NOTIFY:xcb_configure_window(d,*x,mZ?XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT:XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y,(int32_t[]){mZ&&((xcb_motion_notify_event_t*)e)->root_x<=mx?:((xcb_motion_notify_event_t*)e)->root_x-mx,mZ&&((xcb_motion_notify_event_t*)e)->root_y<=my?:((xcb_motion_notify_event_t*)e)->root_y-my});
    else case XCB_BUTTON_RELEASE:xcb_ungrab_pointer(d,XCB_CURRENT_TIME);
    goto main;
    case XCB_UNMAP_NOTIFY:unmap:goto*(x==cs?&&noflush:*x==((xcb_unmap_notify_event_t*)e)->window&&--cz>cs+1?&&stack:(x--,&&unmap));
    }
mvsz:p=xcb_grab_pointer_reply(d,xcb_grab_pointer_unchecked(d,0,rt,XCB_EVENT_MASK_BUTTON_RELEASE|XCB_EVENT_MASK_POINTER_MOTION,XCB_GRAB_MODE_ASYNC,XCB_GRAB_MODE_ASYNC,XCB_NONE,XCB_NONE,XCB_CURRENT_TIME),0);
    if(((xcb_grab_pointer_reply_t*)p)->status!=XCB_GRAB_STATUS_SUCCESS)goto freeflush;
    free(p);
    p=xcb_get_geometry_reply(d,xcb_get_geometry_unchecked(d,*y),0);
    mx=((xcb_get_geometry_reply_t*)p)->x;
    my=((xcb_get_geometry_reply_t*)p)->y;
    free(p);
    if(mZ=mz!=1)goto noflush;
    p=xcb_query_pointer_reply(d,xcb_query_pointer_unchecked(d,rt),0);
    mx=((xcb_query_pointer_reply_t*)p)->root_x-mx;
    my=((xcb_query_pointer_reply_t*)p)->root_y-my;
freeflush:free(p);
    goto noflush;
stack:mx=*x;
    for(;x!=y;x+=x<y?:-1)*x=x[x<y?:-1];
    *x=mx;
hocus:x=cz-1;
    xcb_configure_window(d,*x,XCB_CONFIG_WINDOW_STACK_MODE,di);
pocus:xcb_set_input_focus(d,XCB_INPUT_FOCUS_POINTER_ROOT,*x,XCB_CURRENT_TIME);
    if(!(mz&128))goto main;
kcode:switch(mz&=127){
    case 1:case 3:goto mvsz;
    case 23:case 49:
        if(cz-cs<3)goto main;
        y=tx;
        tx=mz==23?(y!=cs+1?(y?:x)-1:x):!y||y==x?cs+1:y+1;
        if(y&&y<cz-1)xcb_configure_window(d,*y,XCB_CONFIG_WINDOW_SIBLING|XCB_CONFIG_WINDOW_STACK_MODE,(uint32_t[]){y[mz==23?:-1],mz==23});
        xcb_configure_window(d,*tx,XCB_CONFIG_WINDOW_STACK_MODE,di);
        goto main;
    case 25:goto*(p="firefox&",&&cmd);
    case 26:goto*(p="thunar&",&&cmd);
    case 27:goto*(p="dmenu_run&",&&cmd);
    case 28:goto*(p="urxvt&",&&cmd);
    case 38:goto*(p="xfce4-mixer&",&&cmd);
    case 39:goto*(p="slock&",&&cmd);
    case 53:full:
        if(cz>cs+1)xcb_configure_window(d,*y,XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT,di);
        goto main;
    case 24:shut:
        if(cz==cs+1)goto main;
        if(tx)goto*(mz|=128,&&xt);
        p=xcb_intern_atom_reply(d,xcb_intern_atom_unchecked(d,0,12,"WM_PROTOCOLS"),0);
        mx=((xcb_intern_atom_reply_t*)p)->atom;
        free(p);
        p=xcb_intern_atom_reply(d,xcb_intern_atom_unchecked(d,0,16,"WM_DELETE_WINDOW"),0);
        my=((xcb_intern_atom_reply_t*)p)->atom;
        free(p);
        p=xcb_get_property_reply(d,xcb_get_property_unchecked(d,0,*y,mx,XCB_ATOM_ATOM,0,-1),0);
        xcb_send_event(d,0,*y,XCB_EVENT_MASK_NO_EVENT,(void*)(xcb_client_message_event_t[]){{.response_type=XCB_CLIENT_MESSAGE,.window=*y,.type=mx,.format=32,.data.data32={my,XCB_CURRENT_TIME}}});
        for(mx=(((xcb_get_property_reply_t*)p)->value_len<<2)-4;mx>=0&&*(uint32_t*)(p+sizeof(xcb_get_property_reply_t)+mx)!=my;mx-=4);
        if(mx==-1)killit:xcb_kill_client(d,*y);
        free(p);
        goto main;
    case 9:goto*(cz==cs+1?&&main:(p=0,&&killit));
    case 54:p="urxvt +sb -fn xft:monospace-16 -geometry 32x2+500+500 -e sh -c 'date;sleep 5'&";
    cmd:system(p);
    default:goto main;
    }
}


AND here is what it does:

source code is configured to use the following keys:

WinKey - keycode 133 - Hold windows key and then press any of the following keys:
ESC - 9 - kills client window
q - 24 - asks to close client window normally
w - 25 - launches firefox
e - 26 - launches thunar
r - 27 - launches dmenu_run
t - 28 - lauches urxvt
a - 38 - launches xfce4-mixer
s - 39 - launches slock
x - 53 - maximizes window
c - 54 - shows time for 5 seconds
Tab - 23 - cycles forward
grave (~) - 49 cycles backward

WinKey + mouse button1 moves window
WinKey + mouse button3 resizes window

To compile from a terminal use this command:
gcc -o kcwm kcwm.c -std=gnu99 -lxcb

This is all I need from a window manager and it accomplishes all this with under 2 Meg of ram usage. It also closes windows gracefully, Allows proper memory usage, and allows firefox menus to show.

Tuesday, February 04, 2014

imac 27" and linux

It's only been a month with the new imac 27" I got for christmas. I LOVE the hardware, thin, quiet, doesn't get hot, beautiful non-reflective display etc. I believe Apple makes the best computer hardware and no other competitor even comes close including HP, Dell, and Samsung. Some think Apple prices are too high, however when you look at the full specs the 27" display is IPS and that kind of monitor would cost around $1000. The i5 processor, 8G ram, 2G vram nvidia 775, 1tb WD HD, Camera, Speakers, microphones, bluetooth keyboard, bluetooth mouse, etc., would be around $1000 for a pc. In an imac you get all that for $1800 so in a way its actually a bargain. Even though a high initial price.
Anyway after a month of doing almost everything possible in OSX including writing my own applescripts to automate things, installing Homebrew to install all my favorite linux apps, and running Linux in virtualbox. I still missed running linux native. So I downloaded and installed rEFInd and downloaded and installed all my favorite linux distributions. I thought Ubuntu would probably work best on this newest hardware but after trying several different distributions I found that Arch linux actually worked the best. I finally settled on an Arch linux distribution called Manjaro Linux. It even has EFI boot loader support and NVIDIA drivers included so install was quick. I am now writing this on Manjaro Linux and enjoying my iMac.
Some would say, why would you buy an Apple product that has a great OS based on UNIX (OSX) and then replace the OS? For me it's still about choice. 1. I can still not configure OSX to the level I want. 2. Apple wants to promote apps that cost you money (Many great free apps are not included in the Apple App store). 3. The performance I get from linux far exceeds what I can get from OSX.
Is OSX bad? no, its probably the best OS made to date. However, its "walled garden" approach means you have to do everything the Apple way and limits your true potential. The Apple way works and very good for those that want "just works" but very limiting to those that want "I can make it work better".
So in the end, I am a fan of Apple Hardware and appreciate their work to make an OS that works for the masses. However, the geek in me will not allow me to be content with an OS where I can't change the source code or modify every aspect to my liking. I know I am probably in the very minority of computer users these days but why spend
$1800 on the best hardware and settle for something less than gratifying. Now if only Apple would offer a Linux only version of iMac for $1600 :)

Wednesday, December 04, 2013

My yearly update :}

Not updating as often as I used to which is probably a good thing :} I have tried several linux distributions and a few BSD distributions this year. Still love linux and the freedom and control you get. BSD is solid but more geared towards servers. I don't know why but I love getting into the nuts and bolts of my OS. I recently installed arch linux from the command line. It's about as low level as you can get. The nice thing about installing this way is you know the purpose of every file on your system and how to fix things if or when they break.

My favorite thing in linux is to download the source code of programs I like and change things to meet my needs. I'm getting good at reading C code and modifying parts of programs and recompiling. My computer rarely stays the same for two days in a row. There are days I've tried out 3 or 4 linux distributions. I feel sorry for my hard drive at times :}

Recently I discovered that someone involved with Tinycore linux had modified one of my favorite window managers called FLWM. They had moved the titlebar from the left side to the top and moved some buttons around. I decided to download the source code, I modified the config.h file to change the keybindings and compiled. It's now become my favorite window manager. Very fast and lean with unique mouse binds. Again that's the beauty of linux and open source is that anyone can modify or improve the original program.

I still hear from people that linux will never be mainstream, but what they don't know is it already is. So many mainstream programs borrow from linux or opensource software: Android, Webkit (Chrome and Safari browsers), CUPS (printing), Steam (gaming), etc. There are also many opensource programs that have been ported to windows and OSX i.e. The Gimp, VLC, 7zip, etc. Linux is heavily used in Healthcare, Scientific research, and servers. Linux may never be the OS for the average home user due to fact you can change everything including your user interface and there are 100's of distributions to choose from instead of one size fits all. Its opposite of the Apple locked down approach, which prevents the user from changing almost anything. OSX is popular because users that don't want to mess with their computers don't ever need to, things just work because there is only one way to do something. It's possible to install linux and configure it with a similar apple locked down interface, however that's not what Linux is about. It's about software choice and software freedom. I can change or modify even the source code of a program to make it how I choose. This will never be popular with the average user but it sure is with developers as they can simply borrow from someones program make a few changes and release. Some huge corporations are reaping the benefits.

Friday, October 12, 2012

Slackware 14 released, must have it :}

Recently downloaded and installed Slackware 14 on my Desktop Dell i7 computer. Probably one of the easiest installs I've had with Slackware. Either I'm getting better at the command line or Slackware is getting easier. Probably both, however Slackware has one new added tool called "slackpkg". This makes it super easy to keep the distribution updated with security patches. Simply type at the command line as root: slackpkg update [return] slackpkg upgrade-all.

The other tool that has been in Slackware for a long time is called "pkgtool" When you run that as root, you can install new packages, change installation settings, and remove previously installed packages.

Another great tool for Slackware called "sbopkg" isn't part of the distribution but allows you to easily install software from a repository called SlackBuilds.org. It can be downloaded here: http://www.sbopkg.org/ Slackbuilds has most commonly used software programs that are actually tested for each slackware version. I like how I can browse the SlackBuilds web site or search directly from sbopkg.

I find that by using the above command line tools that Slackware is no harder to update or install new software than other common distributions like Debian or Fedora. The video driver installation programs from Nvidia and AMD also work well with Slackware. The beauty about Slackware is that they don't change things just to change things like most distributions. They update packages with each release, but the distribution tools and installation is almost the same as when I first installed it in the late '90s. Stability and Consistency is something rare these days in the world of beta software.

Saturday, May 28, 2011

Dual-boot OSX and LINUX on 2010 Mac Mini (4,1)

I've spent several nights loading various distributions of Linux on my Mac Mini. Since the Mini is based on Intel core2duo it should be easy for someone experienced with linux right? well...its not hard once you understand that the Mini does not use BIOS like PCs do. It uses EFI to boot and has a small 200MB partition that is used to install flash updates (sda1). The Hard drive uses GUID partitioning (GPT). Because of these new technologies and newer hardware, some distributions may not boot. The following covers how to install Ubuntu 11.04 and Debian testing, but will work for most distributions.

Lets start, the easiest and I think best way to dual-boot is to install a boot manager called rEFIt. rEFIt provides a nice icon menu at boot up in which you can select osx or Linux. It also has some nice tools. From OSX, download and install rEFIt. Reboot. Reboot again and the rEFIt screen should come up with icons for osx and various tools. Boot back into osx.

Next, download the 64 bit alternative ubuntu iso. You can use the standard 32 bit Ubuntu if you prefer, just remember to manually partition so that you can select the location for grub. If you prefer Debian, download Debian testing .iso (The stable version didn't recognize the mini's ethernet hardware). Use osx's disk utility to burn the .iso to a CD. Run Bootcamp and select a new partition size (the default 20GB should be fine) and then select "quit and install windows later". Make sure the newly created CD is in the drive and reboot.

When the rEFIt screen comes up select the CD-Rom icon. When the install Ubuntu/Debian screen comes up press F6 and select "nomodeset" or press e and type into boot options (debian). Otherwise you will get a blank screen due to the default nvidia driver that doesn't work fully on mini.

Begin the installation. When you get to the partitioning part, choose manual and then delete the Bootcamp partition. Create a / partition with ext4 and set the boot flag. If you have less than 4gig of ram also create a swap partition the size of your physical ram. You should now have an sda3 / partition and if you added a swap partition, it should be sda4. Towards the end of the installation you will need to install the grub boot loader. The only safe way for future updates is to install to the / or sda3 partition. Type in /dev/sda3 and finish the installation. Reboot...wait it wont reboot..we will fix that later. Hold down the power button for a few seconds to shut off. In case of errors..See Note 1 and 2 below.

Turn on mini and you should now have an icon for Linux on the rEFIt screen. Don't click it yet, instead click on the disk partition icon. Type Y to sync MBR. Click on the OSX icon to boot into osx. Reboot. Back at the rEFIt screen click the Linux icon and after a few seconds the grub menu should appear. Boot into linux. To fix the reboot issue, launch terminal and type "cd /etc/default" and then "sudo gedit grub". Find the line that reads GRUB_CMDLINE_LINUX_DEFAULT, and enter "reboot=pci" at the end of the line. Save the File and exit gedit. At the terminal prompt, type "sudo update-grub"

Now the fun part of configuring everything.. but thats too much to write here :) Enjoy the freedom that apple doesn't allow, such as tiling window managers, etc. P.S. Apple please add a reset button and CD eject button on next mac mini. It's not great having to boot into osx to eject a CD or to reboot by turning off power (i never thought i would miss CNTRL-ALT-DEL). But I guess I could have bought a PC :)

NOTE 1: If you accidently deleted or want to erase SDA1 (in case of corruption) you can restore it by resizing the Hard Drive using osx disk utility (good job apple).

NOTE 2: If you wrongfully installed grub to the MBR or sda, you can fix it by typing "sudo fdisk -u /dev/disk0" in osx terminal.

Monday, January 18, 2010

Another day, Another Launcher for Windows

I've made two more Windows launchers using Autohotkey. Both are activated by using the middle mouse button. The 8-ball or x in the middle hides the gui.

This one I call Picture Launcher:

Here is the graphic you need, copy it to where you put the script: Link
(right click on link, copy location and paste into address bar, then right click and save as)
Here is the source code: link
Here is the exe file: link

This one I call pie Launcher:

Here is the graphic you need, copy it to where you put the script: Link
(right click on link, copy location and paste into address bar, then right click and save as)
Here is the source code: Link
Here is the exe file: Link

Wednesday, November 25, 2009

New programs for Windows

I have made a couple new programs lately with Autohotkey.
This one I call mini Radial:



It appears with middle mouse button under the mouse location and launches my favorite programs.

It uses this graphic: http://www.autohotkey.net/~netfun81/greenorb.png
If you get an error copy URL to address box of browser and paste. Save Graphic to the same folder as the .exe file.

Here is the Exe file: http://www.autohotkey.net/~netfun81/mini radial.exe

Here is the source code: http://www.autohotkey.net/~netfun81/mini%20radial.ahk


This program I call NirCmd Gui:


It is a front-end for NirCmd which is an excellent command line freeware tool.
You can get NirCmd here: http://www.nirsoft.net/utils/nircmd.html

Here is the gui .exe: http://www.autohotkey.net/~netfun81/nircmdgui.exe
Copy to the same folder as NirCmd.exe or copy NirCmd.exe to your windows folder.

Here is the source code: http://www.autohotkey.net/~netfun81/nircmdgui.ahk
Copy to the same folder as NirCmd.exe or copy NirCmd.exe to your windows folder.

Tuesday, November 25, 2008

Arch Linux

It's been awhile again since I last posted. I finally got brave enough to load linux on my new Toshiba Satellite laptop. You know how it goes, when something is brand new you don't want to mess with it too much. Well it only took two months for the new to wear off and for me to feel comfortable installing linux and dual booting with Vista. What distribution did I pick? well you would think I would load Ubuntu since I had no idea if all the hardware was compatable, but since I'm a linux nutcase and never take the easy way out, I decided to install Arch Linux. Arch has become my favorite distribution over the last several months do to its simplicity and great package management. I like to think of it as Slackware with a good package manager that takes care of all the dependencies. However, Arch takes longer for me to install and setup than does Slackware since after installation all you have is core linux. You need to install Xorg, a window manager, firefox, pretty much every application you want.

How did my Toshiba fare? Sweeeeet! All the hardware was recognized. I have intel video, atheros wireless, and realtek audio. All of these are supported by linux. After many hours of installing software and setting everything up, I now have a fast, minimal, Arch setup with DWM as the window manger and Apwal as my launcher. I did have to edit the config.h file before compiling dwm to make it a little more mouse friendly (like close windows with middle click and start apwal with right click on clock).

I have noticed my laptop seems to run cooler running linux over Vista. I think its due to vistas constant thrashing of the hard drive to update its indexing and high memory requirements for the Aero look. I am really happy with Arch and love how easy it is to keep it updated. I find it easier to configure than Debian. Ubuntu and other easy to use distributions are not my cup of tea, since they work well until you need to get to the nuts and bolts and then you find they are messier than they need to be. I am not fond of distributions that are built on other distributions...since you find they sometimes deviate from the way the original distro set things up. Anyway thats all for now...next time I write, everything will probably have changed.

Friday, September 19, 2008

Mouse Launch - small launcher for Windows

This is a small launcher program that I made to appear under the mouse pointer when the middle mouse button is clicked. The buttons are labeled with just one letter to keep the size very small.

Here is what it launches:
C: - ccleaner
E: - explorer
F: - firefox
I: - Internet Explorer
T: - task manager
V: - volume control
L: - logoff windows
R: - Restart windows
S: - Shutdown windows

Hotkeys:
Alt-Space: Hide all windows
Alt-X: Show hidden windows
Lctrl-wheelup: Maximize window
Lctrl-wheeldown: Minimize window
Lctrl-Mbutton: Close window
Lctrl-Rbutton: Switch to next open task

Here is the program: http://www.autohotkey.net/~netfun81/mouse%20launch.exe

Here is the source code: http://www.autohotkey.net/~netfun81/mouse%20launch.ahk

Here is a screenshot: