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)