Switching From Mac To Linux On The Desktop

This will be more of a manifesto then a coding article, will there be code? Of COURSE there will be code, and like all the other posts on this blog it will be broken, and full of bugs, we are, of course, The Bug Shop!

For the purpose of this post, Macs, will include Apples all the was down to the Apple II.

I start my Mac journey at the age of 5, playing reader rabbit on the IIe and I of course didn’t think much of it, my parents popped a 5 1/4 inch disk in the drive and a minute later I was playing. This went on until 1992 when my parents got a brand new Tandy from Radio Shack, and the IIe needed a place to go, and my room was it! I dug through some old boxes and found these spiral bound programming manuals… What a whole new world, I can put a dot at this exact pixel, I could build a Star Wars game, the computer was now under my control. This lasted until about 1994, I would have been 12 at the time. The IIe sadly died, and to my surprise my parents came home with a brand new Packard Bell – 486, Windows 3.1, 4 Megabytes of ram, 15 inch CRT monitor, I was in heaven! Most of the basic code I wrote on the IIe I could get onto this machine.

I went fully Windows at this point in my journey, of course in junior high keyboarding we had some System 7 systems that we were able to boot with “Extensions off” and trash the hard drive. The drove the teacher crazy, we were mostly just assholes. In 1995 something crazy happened, Windows 95. Arguably one of the greatest achievements in operating system history, really wasn’t an operating system at all, just a GUI built on top of DOS, but it was awesome! In fact I was first in line in Yakima Washington to pick up a copy of it. I even got on the 10 o’clock news as “John Hass First customer in line” I was of course on vacation so I had to wait until the end of vacation to install it, but it was done the next week.

Then in 1997 high school hit, we had a Novell network. It was quick and easy to get the admin password… I still remember the password “iko”, basically after that high school was pretty smooth sailing as I could view all of the students work, in their home drives, I could see grades and teacher files, but that is a discussion for another day. With admin access I could also control what applications the students could run. The “Network Admin” thought it was easy to block applications by exe names, so we could play solitaire (sol.exe), but not doom (doom.exe), no problem, I distributed doom.exe as sol.exe to all my friends home drives. We already had an IPX/SPX network, so multiplayer was NO PROBLEM! Still at this point, no Linux, no Macs.

It wasn’t until 1999, that I was at a LAN party, and I saw someone with an unusual looking desktop, he was having a hard time getting the games to run, I asked a buddy of mine what he was using, he said “That’s Linux, it’s too complicated for you” being someone who thrives on being told “it can’t be done” I went to Sioux Falls with my parents and Dad likes to hang out at the magazine racks while Mom shopped, There it was a Linux Magazine… And in that Magazine a CD with Mandrake Linux 5, with KDE desktop. I said “What is this a FREE operating system!?!?!” I paid the 7.99 for the magazine or whatever the price was, took it home and promptly formatted my Packard Bell… LILO boot loaded, what is this!??! So the Rabbit hole began… I ended up putting Windows back on my computer, but found an old 386 and I learned about Redhat, I downloaded it and installed it on the 386.

Well 2000 came, I moved out, the the Mecca of Sioux Falls, got high speed internet (that was nice, coming from dial-up), I took my 386 with me, by this time, it was doing DHCP, DNS, and file storage for me, this “impossible” operating system was seemingly more possible.

Ended up moving to Mankato, chasing a girl (now my wife), but in that move I got a job working tech support for a dial-up ISP, it was one of the greatest jobs I ever had, not the dealing with people, that part sucked. I can’t count the number of times I got hung up on because people thought they could dial-up while I was on the phone with them, I can replay the “Click”, “Dial tone”, in my head. During this time, I was able to hack away on my 386. I was learning PHP / MySQL, the sysadmin for the ISP had a book there, that I stole.

Well the ISP was really bad at handling money and soon there were only 3 of us, The Sysadmin, The owner, and myself. We were promptly purchased and I was let go. Got a Job the following day, selling computers at Computer Renaissance! It was terrible. I wanted to work fixing machines, but the owners wanted me in sales. My adviser at the little Tech school I went to told me about a Job at a school district. So I went and applied, met everyone there and got the Job, Enter Mac’s back into my life. And by this time is was OS X! I had NO idea, that Macs switch from that terrible System 7 closed arch to UNIX!! It was a revelation! A sexy desktop mixed with Unix! I was hooked, I created lots of applications. One of the Applications “X-post Chango” used Unix pipes to allow kids to switch from OS X to os 9 (normally reserved for admins only). I created a package distribution system for OS X. Unix was back baby!

I unfortunately was poor, still borrowing money from Mom to pay the rent (I was 20 at the time) so I couldn’t afford a Mac. Things turned around when I got a Job in Milford, it was really low paying ($12 an hour), but had potential, I was hired as a developer, and Network Admin. At this time I was experimenting with Network Booting Linux, I wanted to build the smallest possible Linux distro that was usable. My Boss at the time saw what I was working on, and we created a product called Thinix, this product still exists today, but not in the same way I built it. We took a plant floor of old pentium 75’s and added a $20 nic, netbooted them all and connected them to a Windows 2003 server with RDP, we saved that company 100’s of Thousands of dollars in desktop cost on the plant floor. After this I was ready to move on in my work life, I was going to be getting married soon, and I thought I needed more then $12 an hour, So I got offered another Job, actually at the plant where we converted all those Desktops to PXE booting machines. I went in and talked to my Boss, and was promptly offered a big fat raise, salary instead of hourly.

Enter Mac OS, After my big fat raise I bought two things. A grill and a used 17 inch Macbook, which my girlfriend (now wife) ordered for me on her school discount.

I slowly restarted replacing all my Windows Desktops with Mac’s. I still always kept a Linux server, but the GUI was Mac. I didn’t start looking back at Linux Desktops until I was looking to create a locked down desktop for a client. I create a product called Novux I started hacking XFCE. XFCE was really cool it was kind of like my Mac, but all in Linux.

October 27, 2016 – Apple unveils the “Mac Book Pro” as with most new Macbooks, I was first in line, I had to have it. Touchbar new keyboard, this thing was the bees knees, all Thunderbolt 3, Charge in ANY port!!! As you probably know from the title of this article, once I got the Macbook, I was less then impressed, a spec of dust in the keyboard could cause the keyboard to stop functioning, My USB-C -> thunderbolt 2 Display adapters don’t work. I had a dream that I could use my laptop as my desktop at work, I had to go dongle CRAZY! I got it working, but it never worked quite right Kernel Panics etc. And the keyboard, oh how I hated the keyboard, it was loud, keys stuck, and the touchbar. WTF.. You mean in my terminal session I don’t get function keys without holding down the FN button, oh but don’t worry they offer easy access to Emojis…. Well as predicted, the keyboard went to shit, and I had to send it in. The next generation of Macbook Pros were out, so I ordered a new one, I figured worst case I could keep sending one in then the other, as the keyboards went to shit. Notice. I am making excuses for Apple at this point, but this is what my thought process was… Crazy Right?!?!

Last month. I had it, I was over it. I was going to switch. I knew I wasn’t going to use Windows, because the majority of my day is stuck in the terminal. I looked at Dells. “Oh, Dell sells machines with Linux now, this could be interesting” We order a lot of servers through Dell so I had one of my employees work with Dell on a machine.

We settled on a Dell Precision 7520, I wanted a 4k monitor, Nvidia graphics, 512GB nvme, and the cellular modem (something I always wanted with Apple, but they just can’t seem to fit it in the slim cases), Dell said they couldn’t put a cellular modem with a 4k monitor, so no big deal, I figured that the slot would still exist so I can work past that. I ordered the machine, and it promptly arrived, I opened it up and yeah sure enough the ngff slot was in there with Antennas!!! So I ordered a EM7455 and put it in, it works fine, I don’t know why Dell won’t put a cellular adapter with a 4k monitor, I assume it’s battery drain.

The machine shipped with Ubuntu 16.04 and everything worked ok, I was disappointed with the Bluetooth support, and I really hated the Ubuntu Desktop, At this point I decided on Debian 9.2, so I formatted, and to my shock the bluetooth was EVEN worse! My mouse would quit after a few minutes. It turned out to be a firmware issue. I replaced with the beta firmware: https://ftp2.halpanet.org/source/_dev/linux-firmware.git/intel/

WOW, even my bluetooth headphones worked better then on my Mac, no stutter, which I always thought was a signal problem (another excuse for Apple), they connected happily right away.

Next problem I want to drive 3 displays (in 4k). The Dell system has one thunderbolt 3 port one HDMI and one mini display port. I found no matter what combination I used I could only drive 2 monitors, so I decided to take the big hammer approach.

https://www.amazon.com/Gigabyte-Aorus-Gaming-Graphic-GV-N1080IXEB-8GD/dp/B076PZ6PRK/ref=sr_1_3?ie=UTF8&qid=1513777725&sr=8-3&keywords=aorus+1080

I cringed at the price, but I thought maybe I could mine some ETH in my spare time to help pay it off, LOL..

This started a week long process of trying to make this thing work.

Here is what I settled on:

Machine boots into Xwindows :0
Then I modified some bumbleed and nvidia conf files:

/etc/bumblebee/bumblebee.conf

# Configuration file for Bumblebee. Values should **not** be put between quotes
 
## Server options. Any change made in this section will need a server restart
# to take effect.
[bumblebeed]
# The secondary Xorg server DISPLAY number
VirtualDisplay=:8
# Should the unused Xorg server be kept running? Set this to true if waiting
# for X to be ready is too long and don't need power management at all.
KeepUnusedXServer=true
# The name of the Bumbleblee server group name (GID name)
ServerGroup=bumblebee
# Card power state at exit. Set to false if the card shoud be ON when Bumblebee
# server exits.
TurnCardOffAtExit=false
# The default behavior of '-f' option on optirun. If set to "true", '-f' will
# be ignored.
NoEcoModeOverride=false
# The Driver used by Bumblebee server. If this value is not set (or empty),
# auto-detection is performed. The available drivers are nvidia and nouveau
# (See also the driver-specific sections below)
Driver=nvidia
# Directory with a dummy config file to pass as a -configdir to secondary X
XorgConfDir=/etc/bumblebee/xorg.conf.d
# Xorg binary to run
XorgBinary=/usr/lib/xorg/Xorg
XorgModulePath=/usr/lib/nvidia/nvidia,/usr/lib/xorg/modules,/usr/lib/nvidia
 
## Client options. Will take effect on the next optirun executed.
[optirun]
# Acceleration/ rendering bridge, possible values are auto, virtualgl and
# primus.
Bridge=auto
# The method used for VirtualGL to transport frames between X servers.
# Possible values are proxy, jpeg, rgb, xv and yuv.
VGLTransport=proxy
# List of paths which are searched for the primus libGL.so.1 when using
# the primus bridge
PrimusLibraryPath=/usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus:/usr/lib/primus:/usr/lib32/primus
# Should the program run under optirun even if Bumblebee server or nvidia card
# is not available?
AllowFallbackToIGC=false
 
 
# Driver-specific settings are grouped under [driver-NAME]. The sections are
# parsed if the Driver setting in [bumblebeed] is set to NAME (or if auto-
# detection resolves to NAME).
# PMMethod: method to use for saving power by disabling the nvidia card, valid
# values are: auto - automatically detect which PM method to use
#         bbswitch - new in BB 3, recommended if available
#       switcheroo - vga_switcheroo method, use at your own risk
#             none - disable PM completely
# https://github.com/Bumblebee-Project/Bumblebee/wiki/Comparison-of-PM-methods
 
## Section with nvidia driver specific options, only parsed if Driver=nvidia
[driver-nvidia]
# Module name to load, defaults to Driver if empty or unset
KernelDriver=nvidia-current
PMMethod=none
# colon-separated path to the nvidia libraries
#LibraryPath=/usr/lib/x86_64-linux-gnu/nvidia:/usr/lib/i386-linux-gnu/nvidia:/usr/lib/nvidia:
# comma-separated path of the directory containing nvidia_drv.so and the
# default Xorg modules path
#XorgModulePath=/usr/lib/xorg/modules
#XorgModulePath=/usr/lib/nvidia/nvidia
#XorgModulePath=/usr/lib/nvidia/nvidia,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input
#XorgModulePath=/usr/lib/nvidia/nvidia,/usr/lib/xorg/modules,/usr/lib/x86_64-linux-gnu/dri
 
XorgConfFile=/etc/bumblebee/xorg.conf.nvidia
#LibraryPath=/usr/lib/nvidia/nvidia,/usr/lib/x86_64-linux-gnu/nvidia/current
LibraryPath=/usr/lib/x86_64-linux-gnu/nvidia/current:/usr/lib/x86_64-linux-gnu/dri
## Section with nouveau driver specific options, only parsed if Driver=nouveau
[driver-nouveau]
KernelDriver=nouveau
PMMethod=auto
XorgConfFile=/etc/bumblebee/xorg.conf.nouveau
Section "ServerLayout"
    Identifier  "Layout0"
    Option      "AutoAddDevices" "true"
    Option      "AutoAddGPU" "false"
EndSection
 
Section "Device"
    Identifier  "DiscreteNvidia"
    Driver      "nvidia"
    VendorName  "NVIDIA Corporation"
 
#   If the X server does not automatically detect your VGA device,
#   you can manually set it here.
#   To get the BusID prop, run `lspci | egrep 'VGA|3D'` and input the data
#   as you see in the commented example.
#   This Setting may be needed in some platforms with more than one
#   nvidia card, which may confuse the proprietary driver (e.g.,
#   trying to take ownership of the wrong device). Also needed on Ubuntu 13.04.
   BusID "PCI:09:00:0"
 
#   Setting ProbeAllGpus to false prevents the new proprietary driver
#   instance spawned to try to control the integrated graphics card,
#   which is already being managed outside bumblebee.
#   This option doesn't hurt and it is required on platforms running
#   more than one nvidia graphics card with the proprietary driver.
#   (E.g. Macbook Pro pre-2010 with nVidia 9400M + 9600M GT).
#   If this option is not set, the new Xorg may blacken the screen and
#   render it unusable (unless you have some way to run killall Xorg).
    Option "ProbeAllGpus" "false"
 
    Option "NoLogo" "true"
    Option "UseEDID" "true"
    Option "AllowSHMPixmaps" "false"
    #Option "UseDisplayDevice" "none"
    Option "AllowEmptyInitialConfiguration" "true"
EndSection
 
Section "Screen"
	Identifier "Screen0"
	Device "DiscreteNvidia"
EndSection
 
Section "Monitor"
	Identifier "Monitor1"
	Option	"ConnectedMonitor" "DP-4"
EndSection
 
Section "Files"
  ModulePath   "/usr/lib/nvidia"
  ModulePath   "/usr/lib/xorg/modules/"
EndSection

then to start X I needed to use optirun, but I wanted it as me not as root (I didn’t create this script, I did modify it)

OptimusStart.sh

#! /bin/bash
# Starts a separate X session using Optimus
# and uses separate input devices for each
# must be run as root, with 'optirun'
 
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi
 
#Need to Kill Pulse Audio So we can use H2DP
#su ${SUDO_USER} -c "killall -u ${SUDO_USER} pulseaudio"
 
# First, disable external inputs on internal screen's X server
# Replace these with the names of your EXTERNAL input devices.
#xinput disable keyboard:"Metadot - Das Keyboard Das Keyboard"
#xinput disable keyboard:"AT Translated Set 2 keyboard"
IDS=`xinput --list |grep -i Metadot | awk '{ print $8 }' | cut -d "=" -f2`
for i in $IDS; do
	xinput disable $i
done
xinput disable pointer:"MX Anywhere 2"
 
# Save current DISPLAY variable so we can use it later
ORIGDISPLAY=$DISPLAY
# Set display ID to the external screen's X server
DISPLAY=':8'  #<-- This should be the value of 'VirtualDisplay' from earlier.
 
# Disable internal inputs
# Replace these with the names of your INTERNAL input devices
#xinput disable "AT Translated Set 2 keyboard"
#xinput disable "DualPoint Stick"
 
# Start another session.  This example is for XFCE or Xubuntu, look up the appropriate
# command for your desktop environment of choice and replace 'xfce4-session'.
# Remember to replace USERNAME with your username.
su -c xfce4-session ${SUDO_USER} > /dev/null 2>&1
# (this script pauses here until the new session ends)
 
# Switch back to the internal screen's X server
DISPLAY=$ORIGDISPLAY
 
# Re-enable external inputs on the internal screen's X server
#xinput enable keyboard:"Metadot - Das Keyboard Das Keyboard"
#xinput enable keyboard:"AT Translated Set 2 keyboard"
xinput enable pointer:"MX Anywhere 2"
IDS=`xinput --list |grep -i Metadot | awk '{ print $8 }' | cut -d "=" -f2`
for i in $IDS; do
	xinput enable $i
done
#PID=`ps aux |grep /etc/bumblebee/xorg.conf.nvidia | grep -v grep | awk '{ print $2 }'`
#killall -9 $PID
systemctl restart bumblebeed

One really messed up thing the machine does is when you move your mouse on your live Xsession it also does back on :0, so disabling the keyboard and mouse on :0 is super important.

Edit the script and get the devices

xinput --list

Change it in the script.

now, I can start my Xsession

killall pulseaudio
sudo optirun -b none ./OptimusStart.sh

I killed pulseaudio because bluetooth Audio won’t share between the desktops.

and Boom my monitors happily lit up and showed a desktop! I was almost home free.

So when I wanted to go mobile I needed to be able to unplug my eGPU plugged into the thunderbolt. as you can imagine PANIC FREEZE!!! That’s when I learned that thunderbolt 3 is actually an extension of the PCIe bus, LOL, I guess you should expect a panic when you rip video cards out.

Another script I pieced together from other scripts I found online, this allows me to unplug the Thunderbolt 3.

unplug.sh

#!/bin/bash
 
PID=`ps aux |grep xorg.conf.nvidia |grep -v grep | awk '{ print $2 }'`
kill -9 $PID
rmmod nvidia_modeset
rmmod nvidia
 
secs=10
tbt_chain=/sys/bus/pci/devices/0000:01:00.0
 
echo "Unplug eGPU script started."
if [ "$(id -u)" != "0" ]; then
	echo "Please run using sudo. Exiting."
	exit 1
fi
if [ -e $tbt_chain/remove ]
then
	echo 1 > $tbt_chain/remove
	echo "Thunderbolt chain removed from PCI tree. Please unplug eGPU now."
	while [ $secs -gt 0 ]; do
   		echo -ne "$secs to rescan...\033[0K\r"
   		sleep 1
   		: $((secs--))
	done
	echo 1 > /sys/bus/pci/rescan
	echo "Rescanned the PCI bus. Completed."
	exit 0
else
	echo "eGPU does not appear to be attached. Exiting."
	exit 1
fi

One last annoying problem, whenever I started the X session on the Nvidia cards The screens always mirror because I plug a cable into the mDP on the Dell. So I found this program called: Arandr, it’s a graphical frontend to xrandr, and outputs a script with all the xrandr commands you need to fix the desktop. Here is mine:

#!/bin/sh
xrandr --output DVI-D-0 --off --output HDMI-0 --off --output DP-5 --off --output DP-4 --mode 3840x2160 --pos 3840x0 --rotate normal --output DP-3 --off --output DP-2 --mode 3840x2160 --pos 7680x0 --rotate normal --output DP-1 --off --output DP-0 --mode 3840x2160 --pos 0x0 --rotate normal

I just double click that and my monitors work well.

Couple of last things.

1. Email support. I really liked Mac OS Mail. Evolution is Extremely buggy (I use exchange mail) I found mailspring, it’s cool, but it ONLY supports exchange, I also have imap accounts. I found a plugin for Thunderbird, which costs $10 a year I am testing it, I will probably end up using that, along with the EWS calendar.

2. iMessage.. I really really miss iMessage, Getting everyone to switch to Telegram has been a hassle, I think in the end I will get it done, but I miss iMessage

3. Passwords. Exporting icloud passwords is a pain in the ass (I use keychain access) https://gist.github.com/rmondello/b933231b1fcc83a7db0b

But that didn’t copy all the passwords. The only reason that I use the mac anymore is to get a password or file off of it.

I still have my iPhone, until I get people to all switch to Telegram, So syncing pictures is important to me.
https://github.com/ndbroadbent/icloud_photos_downloader

/home/john/icloud/icloud_photos_downloader/download_photos.py –username xxx@gmail.com –download-videos –size=original –until-found=5 /home/john/Pictures/

in summation or TL;DR – Apple has really lost their way, and I know I am not the only person that has been frustrated by what they have done. While my actions are probably more extreme then most, Apple has lost my respect, and will have to work hard to get it back..

Have Fun!

John “There is no cloud, it’s just someone else’s computer” Hass

Yeah that purple is the lights off the Aorus.. They could really have done without that

Leave a Reply

Your email address will not be published. Required fields are marked *