Wednesday, February 1, 2017

Blurry font issue with Wine 2.0 on macOS 10.12.2

After installing the latest Wine release, which currently is 2.0 (I chose the development branch) on XQuartz 2.7.11, I was having problems with blurry text in both winecfg, regedit and other programs launched through Wine.
After trying to enable font smoothing and font replacements (source) with only slight changes I found someone trying to solve the same issues (source), albeit compiling everything from scratch which I don't want to do.
It turns out that the Retina display on my MacBook Pro was causing the issues with blurry fonts because Wine was not using the "real" resolution, only the reported "lower resolution".

To enable Retina support in Wine open the registry editor via a terminal, preferably through Wine Devel.app installed with Wine:
$ wine regedit

Then find the folder/key:
HKEY_CURRENT_USER\Software\

I then had to create the folder/key called "Mac Driver" and inside the new folder/key create a new string value called RetinaMode. Now edit the value of the RetinaMode to be "y".
Picture showing the location of the new value to enable Retina support for Wine on macOS.
Path is: HKEY_CURRENT_USER\Software\Wine\Mac Driver\
Close the registry editor and restart wine:
$ wineboot
Then open Wine configuration dialog:
$ winecfg
The window will now be very small due to Retina support being enabled. Navigate to Graphics and select a screen resolution scaling of 220 dpi.
Close the Wine configuration dialog and restart wine again:
$ wineboot

That's it, next time you open a program (e.g. Wine configuration dialog) it will be the correct size and with smooth fonts.
The windows terminal that is launched by:
$ wineconsole
Uses other font/scaling settings so it is necessary to choose another font size by right clicking the program and navigating to properties. Then select Font and choose a font size larger than 28, remember to select "retain the for later sessions" to save the settings for new windows.

Thursday, January 5, 2017

Applescript control of bluetooth and wifi - ADVANCED

I made a more advanced script for controlling (not flipping) the bluetooth and wifi power states (see previous post for finding the correct menus).
This script is looking for a certain USB device that will indicate whether the computer is docked or not.


-- Applescript that searches connected USB devices and determines if this means the computer is docked or not.
-- In docked mode bluetooth should be On and wifi Off, and vice versa for undocked.

------- BEGIN USER CONFIG -------
set list_cmd to "system_profiler SPUSBDataType"
set search_str to "AX80_EXT_HUB"
-------- END USER CONFIG --------


---------- BEGIN SCRIPT ----------
set shellOut to ""
try
set shellOut to do shell script list_cmd & " | grep " & quoted form of search_str
end try
if shellOut contains search_str then
set state_docked to true
else
set state_docked to false
end if

if state_docked is true then
set state_bluetooth to "On"
set state_wifi to "Off"
else
set state_bluetooth to "Off"
set state_wifi to "On"
end if

set menu_bluetooth to 0
set menu_wifi to 0
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set menu_extras to description of menu bar items
repeat with x from 1 to the length of menu_extras
if item x of menu_extras is "bluetooth" then
set menu_bluetooth to x
exit repeat
end if
end repeat
repeat with x from 1 to the length of menu_extras
if item x of menu_extras starts with "Wi-Fi" then
set menu_wifi to x
exit repeat
end if
end repeat
if menu_bluetooth is greater than 0 then
tell menu bar item menu_bluetooth
click
if name of menu item 2 of front menu ends with state_bluetooth then
tell menu item 2 of front menu
click
end tell
else
tell application "System Events"
key code 53
end tell
end if
end tell
end if
if menu_wifi is greater than 0 then
tell menu bar item menu_wifi
click
if name of menu item 2 of front menu ends with state_wifi then
tell menu item 2 of front menu
click
end tell
else
tell application "System Events"
key code 53
end tell
end if
end tell
end if
end tell


----------- END SCRIPT -----------

Wednesday, January 4, 2017

Applescript control of bluetooth and wifi

Here's a small script that will flip the state of both bluetooth and wifi radios on your Mac.
It is tested on a macOS Sierra 10.12.2, and the descriptions ("bluetooth" and "Wi-Fi") may be altered in previous (or future) versions. Read on below if you need to change this.

tell application "System Events" to tell process "SystemUIServer" to tell (menu bar item 1 of menu bar 1 whose description is "bluetooth") to {clickclick (menu item 2 of menu 1)}


tell application "System Events" to tell process "SystemUIServer" to tell (menu bar item 1 of menu bar 1 whose description starts with "Wi-Fi") to {clickclick (menu item 2 of menu 1)}

To learn the correct description terms open Accessibility Inspector and choose point to inspect (crosshair), then select the menubar item that should match the description. The description is the label name in Basic section. Be aware that the label may change depending on the state of the menubar item (e.g. Wifi changes the trailing string after "Wi-Fi" depending on the connection status, whereas "bluetooth" does not)

Monday, August 10, 2015

[Updated] Fix for slow shutdown when using Synology CloudStation client on OSX


UPDATE: As of version 3.2-3487 of the CloudStation app the slow shutdown times have been fixed (at least on OSX 10.11 El Capitan). Note that the older versions still had problems on OSX 10.11 El Capitan, and only the listed version seems to fix this on my 2013 13" Retina MBP.

I've noticed that my mac is experiencing slow shutdown times (~30-50 sec slower than usual) when the Synology CloudStation client/app is running. This has been seen on version: 3.2-3482 and one version earlier.

Doing some diagnostics I noticed that the process "cloud-eventd" was not terminated even when the CloudStation client/app was told to terminate. This process would then make the system wait for a graceful termination before continuing the shutdown (or reboot) process. And this is what caused the delay of ~30-50 sec.

I've been in contact with support twice, but so far no fix has been published and I've instead created an AppleScript that is able to detect if both the client/app and the offending process is running and then terminate both.

Upon completion it will then give the possibility of shutting down, restarting or nothing.
Here's a screenshot showing the dialog.


The script is pasted below and I would recommend that the script is exported as an application so you can easily call it from e.g. Spotlight. (I named mine powerOff.app)
NOTE: The script needs admin rights to kill the "cloud-eventd" as it is owned by root. As a result there will be a request for an admin password if the process is to be terminated.


set no_action to "- No action performed"
set answer to no_action

set app_name to "CloudStation"
if application app_name is running then
tell application app_name to quit
set answer to "- Application " & app_name & " terminated"
delay 2
end if

set proc_name to "cloud-eventd"
set the_pid to (do shell script "ps ax | grep " & (quoted form of proc_name) & " | grep -v grep | awk '{print $1}'")
if the_pid is not "" then
do shell script ("kill -9 " & the_pid) with administrator privileges
if answer is no_action then
set answer to "- Process " & proc_name & " terminated"
else
set answer to answer & "
" & "- Process " & proc_name & " terminated"
end if
end if

set reaction to the button returned of (display dialog "CloudStation killer:
" & answer buttons {"Shutdown", "Reboot", "Dismiss"} default button 3)

if reaction is "Shutdown" then
tell application "Finder" to shut down
else if reaction is "Reboot" then
tell application "Finder" to restart
end if

Friday, July 31, 2015

Removing OneDrive shorcut in File Explorer (Windows 10)

So I just installed Windows 10 and was instantly annoyed by the OneDrive integration. After disabling auto-start and closing the program I noticed that there is a fixed shortcut in File Explorer.

On youtube I found a video that explained to enter Registry Editor and remove these two keys:
- HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}
- HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}
NOTE: YOU MAY WANT TO EXPORT THE KEYS BEFORE DELETING THEM, IN CASE YOU WOULD LIKE TO USE ONEDRIVE IN THE FUTURE.

The fix is instant, but you must close all File Explorer windows before the changes take effect.

Friday, February 7, 2014

xbox one power supply pinout

So I brought a new xbox one back from US to Denmark and realized (the hard way, aka smokey) that it is not usable on the 230V outputs.

xbox support has been helpful and I can buy a new 230V through them for 32.9 EUR plus 5.0 EUR shipping.

While I wait for that one I'm looking at how to power the xbox one using a PC (ATX) power supply. A lot of guides exists for the xbox 360 online, but I wasn't able to find the pinout of the xbox one power supply. So I simply took the damaged power supply apart and mapped out the pins:

Type          Color           Rating      Note
GND         Black/Grey      -           GND_5V is grey, but internally connected to GND.
12V           Yellow         17.9 A
5V             Red               1.0 A
PWRON   Blue                 -           Must be used for communication between xbox and PSU.

image_missing-xbox-one-power-supply-pinout
The upper left insert in the image above shows how the colored wires are arranged in the plug from the power supply: GND (black & grey) is on both outer walls of the two cylinders and 12V are on both inside walls. Looking into the plug (not into the xbox one!) the pin inside the LEFT cylinder is PWRON and the PIN inside the right cylinder is 5V (when the plastic "bridge" between the cylinders is flat on top and curved curved underneath).

Follow any xbox 360 ATX power supply guide (like this: http://www.xpgamesaves.com/topic/21589-tutorial-xbox360-power-supply-mod-pc-psu/) but remember to use the PWRON pin to enable communication between the xbox one and the power supply.

Also note that the power supply in use must be able to deliver 17.9A at 12V (yellow wires) and 1A at 5V (red wire).

Happy modding!

Monday, October 28, 2013

Disabling auto- emoticons/emoji/smiley in OSX 10.9 Mavericks for Messages app

Here's a thing that bugged my since upgrading to OSX 10.9 Mavericks: The messages app kept changing regular ascii-emoticons such as ":)" to the build-in icon type emoticons known from iOS...

Since searching the web didn't produce results from OSX 10.9 Mavericks I had to figure it out myself. There is no way to change this in settings, and the way it was done in OSX 10.8 Mountain Lion (right click the conversation area and choose "Show Smileys)" was not available.

The simple way to disable the auto-emoticons is to right click in the text input area, select Substitutions and click on "Emoji" (or "Text Replacement" in general if you do not like that).

The screenshot shows where to locate the option.