emacs: change font size based on display resolution

This is my first attempt to customize my spacemacs. Bare with me, I just looked at some elisp examples the last few hours and came up with this:

;; Change font-size based on screen resolution
(setq crappy-projector-theme-loaded nil)
(defun fontify-frame ()
  (cond ((> (x-display-pixel-width) 2600) (text-scale-set 0)) ;; docked
        ((< (x-display-pixel-width) 1100) (progn
                                            (text-scale-set 2)
                                            (load-theme 'spacemacs-light t)
                                            (setq crappy-projector-theme-loaded t)
                                            )) ;; crappy projector
        (t (progn
            (text-scale-set 1.2)
            (if (equal crappy-projector-theme-loaded t)
                (progn
                  (load-theme 'spacemacs-dark t)
                  (setq crappy-projector-theme-loaded nil)
                )
            )
        ))
    )
)
(add-hook 'window-configuration-change-hook 'fontify-frame)

What I need from emacs:

At university, there are some occations where I need to present some code in front of the class. There is always the problem with bad (I mean, really bad) projectors in our classrooms. You can't really see something when you project something with black background and white font. It's since a habit to switch to another theme in whatever editor you're using and tremendesly increase the size of the font used. It's crappy as hell, and I don't want to spend too much thought with wit.

With the little function above I'll catch more than one circumstances, when changing textsize is handy: In the university as soon as a projector is connected, and at home where I dock my notebook and use a ultrawide 32" display. At home, the display is large - and most of the time it's there where I sit and work. This should be my basis. At the university, most of the projectors are pretty old, and only support 800x600px or 1024x768px. That's my second environment to switch textsize and in this case the theme too. The default case is when I'm on the way and when I'm using the notebook display - it's resolution is right in between the other cases.

If the display resolution is above 2600px -> Ultrawide Display at home

If the display resolution is below 1100px -> a crappy projector is used

If none of the above is the case, I'm probably using the built in display of the notebook.

So far, this function works. Maybe I built in some errors, but usually thats the fault of elisp. It's the first time I used it myself, and I don't think we will be friends any time soon...

Parole Media Player won't start - segfault!

starting parole media player caused it to segfault. On the command line at least I got a clue what's going on - parole complained about some files it didn't find anymore. The big asscrack I'm complaining about: google didn't reveal the location where this information is stored! I hate that -> Developers: Please, please tell us where your software is storing it's (config) files!

After a little search on my system, I found this file:

~/.local/share/xfc4/parole/auto-saved-playlist.m3u

Yep - there are the entries parole is complaining about - so, deleting it should fix the problem...

NOPE!

Starting parole from the command line is segfaulting. This time without any clues what's wrong... OK, well, then... just delete that damn auto-saved-playlist file.... and, big reveal: parole works again.

The thing is: I have not found a really really good audio player that integrates seamlessly into my setup (xfce, i3) - most mediaplayers have some ridiculous themes going on, pleae don't try that with i3... wont work at all. I need a simple application which can play all media files, gives a simple ui that can handle being in an tiling environment, keeps track what I'm playing and is in general hassle free.... didn't find anything yet...

SteamLibrary on the Network

My gaming machine has an old problem: Never enough free disk space. My NAS on the other hand has about 5 TB of it, why not using it for the SteamLibrary. Unfortunately, there is a small problem with Windows 10. It won't allow you to exectue files from a NAS right away. You need to tweak the registry to be able to play from your NAS.

Here is the official Microsoft technet entry:

https://technet.microsoft.com/en-us/library/ee844140(v=ws.10).aspx

Add a DWORD Value of 1 to HKEY_LOCAL_MACHINE/SOFTWAREMicrosoft/Windows/CurrentVersion/Policies/System/EnableLinkedConnections and restart.

Next, since I already had some games in my SteamLibrary Folder on my nas, i had to recursely change persmissions. Rightclick your SteamLibrary Folder on your NAS (which is mapped as Network Drive), goto Permissions > Security > Advanced Security. Select Everyone > Edit and allow Full Control. Then tick "Replace all child oibject permission entries..." and hit Apply. This should change all security permissions in all Folders/Files in the SteamLibrary.

For me, these changes worked. I don't really care about permission settings for the SteamLibrary - This is only for the Windows machine only.

The only problem I found so far was that "supermeatboy" will crash, but I don't know jet if it's just because it's installed on an network drive.

Docking A ThinkPad T460s

For my workstation setup at home I needed a convenient way to switch off the display on my notebook, switch on the external monitor, change the resolution, and do some other things. I found this blog entry which is describing exactly what I needed, and on top of that, it's even the same setup that I use (i3, ubuntu, T460s).

Here is my /etc/acpi/external-monitor.sh

#!/bin/sh
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority

if [ "$1" = "dock" ]; then
        logger "ACPI event: Turning on DP2-2. This will take 10 seconds or so..."
                while (xrandr | grep "DP2-2 disconnected"); do
                        sleep 1
                done
        sleep 1
        logger "docking"
        xrandr --verbose --output eDP1 --auto --output DP2-2 --off 2>&1 | logger
        sleep 1
        xrandr --verbose --output eDP1 --off --output DP2-2 --auto --primary 2>&1 | logger
else
        logger "ACPI event: Turning off DP2-2"
        xrandr  --verbose --output DP2-2 --off --output eDP1 --auto --primary 2>&1 | logger
fi

Here is my /home/user/.Xmodmap

! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

Of course, to get everything working, there are two additional files needed.

my /etc/acpi/events/thinkpad-dock

event=ibm/hotkey LEN0068:00 00000080 00004010
action=su user -c "/etc/acpi/external-monitor.sh dock"

my /etc/acpi/events/thinkpad-undock

event=ibm/hotkey LEN0068:00 00000080 00004011
action=su user -c "/etc/acpi/external-monitor.sh undock"

These configs are far from perfect. Sometimes I have the problem, that switching on the external output fails - I have no idea why. When this happens, this script already disabled my notebook display, and I have not really a chance to turn it back on blindly. For the moment, a hard reset of the notebook (turning it off by holding the powerbutton for a few seconds and restarting) is the fastest workaround for this problem. (On my system, everything should be saved to disk anytime anyway, so I don't fear loosing data that much)

Additionals / User specific:

I added these lines below the xrandr statement to fulfil some user specific configs when docked:

xmodmap /home/user/.Xmodmap

To switch caps-lock and esc buttons. Somehow ubuntu ignores my default keymapping on external keyboards.

I also extended my external-monitor.sh by this line to enshure that as soon as my notebook is docked a backup is made and sent over ethernet:

rsync -azt --exclude '.local/share/Trash/' /home/user/ server:/backups/hostname/
rsync -azt /etc server:/backups/hostname/

Hello World!

I am finally getting around to get a website up and running to give some insights to my doing, what I feel went wront and to what will fail in the future. Let me be straight from the first Moment on: I am not an expert in anything I'll be talking about. Ever. I do know some things, or have some experience in some expertieses (<- yeah, look at this), and my english needs some training as well. So, bare with me, hope for the best and try not to just see the bad sides...