Skip to content

Instantly share code, notes, and snippets.

@porteusconf
Last active March 6, 2023 15:16
Show Gist options
  • Save porteusconf/cd1de43d4cab3cce8a3454a672d550f7 to your computer and use it in GitHub Desktop.
Save porteusconf/cd1de43d4cab3cce8a3454a672d550f7 to your computer and use it in GitHub Desktop.
lauches gui-app qgle.app (should work if you choose newer/older versions of gle by `brew switch gle`) 64-bit gle 4.3.0 Tested on macos 10.15
#!/usr/bin/env bash
## Put this qgle.command in /Applications and in Terminal:
### chmod a+x /Applications/qgle.command
### assumes you installed gle in /usr/local/cellar and did brew link similar to following...
## brew diy --name=gle --version=4.3.0
## mkdir /usr/local/Cellar/gle
## cd /usr/local/Cellar/gle
## tar zxf gle_macosx_4.3.0_x64.tar.bz2 # download newest tarball from sourceforge
## mv /usr/local/Cellar/gle/gle-4.3 /usr/local/Cellar/gle/4.3.0
## brew link gle
### After you have done the above, then you should see a symlink like this:
### ls -l /usr/local/opt/gle ###
### lrwxr-xr-x /usr/local/opt/gle -> ../Cellar/gle/4.3
### And if so, then next line should open the gui qgle.app
export GLE_TOP=/usr/local/opt/gle; open /usr/local/opt/gle/bin/qgle.app
echo "/usr/local/opt/gle/qgle.app should be running..."
sleep 7
exit
@porteusconf
Copy link
Author

porteusconf commented Nov 9, 2020

Version 3.4.0 released 2020-Nov-05 of gle software is 64-bit and so will run on macos 10.15 and newer https://glx.sourceforge.io/ When I have time I may try to make a homebrew gl.rb formula for macos and linux. Until then, try this:

brew intall ghostscript
brew cask install mactex
## brew  diy --name=gle --version=4.3.0
mkdir /usr/local/Cellar/gle
cd    /usr/local/Cellar/gle
tar zxf gle_macosx_4.3.0_x64.tar.bz2 # download newest from  https://glx.sourceforge.io/ 
mv /usr/local/Cellar/gle/gle-4.3  /usr/local/Cellar/gle/4.3.0 # adjust version number as needed
brew link gle
## Download or create qgle.command file (above)
cp qgle.command /Applications;  chmod a+x /Applications/qgle.command
brew link gle

None of this should need to be changed if/when a new version of gle or qgle comes out. May even be able to switch which version of gle and qgle app you use with brew switch gle command. The trick is the /usr/local/opt magic of brew

@porteusconf
Copy link
Author

Currently nobody seems to have a tap with gle.rb homebrew formula. Google did find a 2014 issue for gle on now defunct homebrew/legacy tap: Homebrew/legacy-homebrew#28349 If qgle or gle requires x11 libs, that may be why homebrew no longer has a gle.rb formula.

I'll see if I can find a old copy of the formula to hack on ...may have to use wayback machine/internet archive? And/or work off of the macports scripts https://github.com/macports/macports-ports/blob/master/graphics/gle-graphics/Portfile
Anyways, while waiting for more info on setting up gle with homebrew, of interest to gle/qgle users may be these taps by others to enable building of x11 graphical binaries, since homebrew out-of-the box no longer supports builds against x11 libs.
For example, the first tap can provide 'gv` command to view postscript etc in xquartz/x11.
The Homebrew ghostscript no longer supplies gv: only non-graphical ghostview commands like the ps2* and pdf2* binaries seen in /usr/local/Cellar/ghostview/*/bin/ folder.

# tap to enable builds against defunct gs x11 libs. (in 2020-12 seems  very well-maintained, tracking homebrew ghostscript versions.)
brew install johnhcc/gs-x11/ghostscript-x11   # provides  X11-enabled binaries directly at $(brew --prefix)/opt/ghostscript-x11/bin.
brew install johnhcc/gs-x11/gv  # provides gv

# well maintained tap to provide 'Homebrew ImageMagick with X11 support'
brew uninstall imagemagick  # without x11 support
brew cask install xquartz
brew install tlk/imagemagick-x11/imagemagick

###  hacky beta-quality tap to provide modern fonts and "X11 libs for Homebrew"
brew install dk/x11/xorg-macros
brew install dk/x11/libxft

@porteusconf
Copy link
Author

porteusconf commented Jan 25, 2021

Note: Around Feb 2021 I hope to have time to consider the issue on macos of getting double-click to open a file in qgle. See:
https://sourceforge.net/p/glx/mailman/message/37159497/

Dear all,

I was wondering whether anyone could help me out with this (admittedly small issue of the new version on a MAC):

a) Whenever I try to open a .gle file by double clicking, QGLE opens, but the file is not loaded

b) dragging and dropping said -gle file to QGLE results in the following error message "Dropped file cannot be opened"

c) running "gle -p file.gle" on the command line (i.e. trying to invoke QGLE) also gives an error message
"Error: could not connect to GLE preview application, code = -1"
Now, this is not extremely horrible, but just a bit annoying, as I can still open files using the "File -> Open" option within QGLE (when started separately).
Nonetheless any suggestion from other (MAC) users would be more than welcome.

Additional info: I installed GLE via homebrew following the instructions given in https://gist.github.com/porteusconf/cd1de43d4cab3cce8a3454a672d550f7

Thanks

Ulf

--
Arnulf Rosspeintner

Départment de Chimie Physique
Université de Genève
30, quai Ernest-Ansermet
1211 Genève 4, Switzerland
Tel.: + 41 22 379 65 56
http://www.unige.ch/sciences/chifi/2Buergi


Ulf:
I wonder if this is due to the use of the old and outdated version of the cross platform GUI library Qt 4.8.
The version of QGLE you are using is built against that old version.
I currently have it building with Qt 5 plan to do a release this week or next.
This may solve that problem (hopefully). Keep me posted when it comes out.
Vince


As of Jan 2021 in a quick look at sourceforge I did not see a release for macos-64bit that was, at least obviously, built against qt5 instead of 4.8, as Vince mentioned in the only reply (so far, as of Jan 24, 2021).

In googling for info on how to build it againtst qt5, I noticed that 7 days ago around Jan 17, 2021 the portfile was changed to link against jpeg-turbo libs, even tho the portfile has no maintainer: macports/macports-ports@0c3c5e7
And it looks like builds have been failing for 10.14 and 10.15 for a while now: https://ports.macports.org/port/QGLE/tickets

@porteusconf
Copy link
Author

You can use an Automator wrapper on macos as a "trick" to get a double-clicked item to be opened with a bash script, as detailed here:
[https://superuser.com/questions/239231/osx-open-with-bash-script/827006#827006]https://superuser.com/questions/239231/osx-open-with-bash-script/827006#827006l)

I think something similar would work so double-clicking *.gle files on macos would get them to open in newer (or older) qgle gui app.
When I get a chance to work out exactly how to get double-clicking of *.gle to work as wanted, I'll update this gist.

@porteusconf
Copy link
Author

Fix for qgle 4.3.3 on newer debian (like bullseye) if you get missing libicu*66 libs and/or qgle: undefined symbol: u_strToLower_66
Issue is that newer Debians/ubuntus provide libicu67 and the libicu66 we need is not in the repos, but you can install manually without removing libicu67 (or libicu57). The fix below worked on my sparky-linux rolling debain-bullseye system (with all updates/upgrades as of Sept 2022), even tho the libicu66.deb came from ubuntu website.

wget 'http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb' -O /tmp/libicu66.deb
sudo dpkg -i /tmp/libicu66.deb
### Now qgle 4.3.3 runs on 5.10.0-16-amd64 #1 SMP Debian 5.10.127-2 (2022-07-23) x86_64 GNU/Linux

@porteusconf
Copy link
Author

Using curl will avoid macos warnings/quarantines of "untrusted" binary executables, like gle and qgle.app files.

cd /Users/Shared/
curl  -LJO  https://github.com/vlabella/GLE/releases/download/4.3.3/gle-4.3.3-Darwin.zip
unzip gle-4.3.3-Darwin.zip
cd /Users/Shared/gle-4.3.3-Darwin/bin
./gle. --version
open. qgle.app/

Both gle and qgle.app should run without you having to allow them in SysPrefs->Security. I think this is because:
"There is no quarantining flag for a CLI app downloaded with curl." per https://stackoverflow.com/questions/67446317/why-are-executables-installed-with-homebrew-trusted-on-macos

@porteusconf
Copy link
Author

porteusconf commented Sep 30, 2022

== How to fix fonts warning from qgle on macos ==
On macos 12 (aka "monterey"), we saw warning below in Terminal (running qgle inside `qgle.app/Contents/Macos). Warning can only be easily seen in terminal, and is not seen or hidden/discarded when lauching the app by double-click of the qgle.app in Finder).

$GLE_TOP/bin/qgle.app/Contents/MacOS/qgle
qt.qpa.fonts: Populating font family aliases took 429 ms. Replace uses of missing font family "Courier" with one that exists to avoid this cost. 

Cause: macos ships with "Courier New" but not "Courier" as detailed here: https://discussions.apple.com/thread/253481507
Fix: Download a Courier font-file and install with Fontbook.app (to "Computer" if you are admin, or just "User" if you are not admin).
At https://discussions.apple.com/thread/253481507?answerId=256515086022#256515086022 Tom Gewecke posted a dropbox link https://www.dropbox.com/s/0ideg56xq7pry41/Courier.dfont.zip?dl=0 to download 586380 byte Courier.dfont.zip file that came with Catalina (aka Macos 10.15). And Fontbook installed it ok on macos 12.6. Once Fontbook installed and enabled Courier.dfont file, then qgle no longer displayed that font warning (or any other warnings). No need to disable "Courier New" which is different from "Courier": they do not interfere and are independent of each other.

(Note: Also tried a 60856 byte 09809_COURIER.ttf file but Fontbook found many problems and warned not to install it.)
If anyone finds a Courier.ttf that works, please post it, as apple has been deprecating *.dfont in favor of truetype, so it would be better in long run to use a Courier.ttf rather than apple's propietary Courier.dfont file.

@porteusconf
Copy link
Author

Well, it is 2023 now, and some of the advice above may or may not still be useful. The gle source code and binary packages are now on github at https://github.com/vlabella/GLE and I was even able to get it compile and run, tho with a flaw, on both intel and apple-silicon macos12 (monterey) and/or macos13 (ventura). I tried to fix the flaw, but gave up as it was easier to get qGLE running in a UTM-provided debian-11 vm on both intel and apple-silicon macs. The flaw and attempted fixes are issue 2 at GLE github site vlabella/GLE#2

@porteusconf
Copy link
Author

porteusconf commented Mar 6, 2023

=== Quick-start: How to setup a vm on macos to run qgle ===

  • To run vm (virtual machine) on macos host, we'll use free UTM.app. brew update utm-beta Note: You can buy for $10 the macos-version of UTM in the App Store. Or, get it free from https://mac.getutm.app/ where is says: "What's the difference in the Mac App Store version?
    UTM is and always will be completely free and open source. The Mac App Store version is identical to the free version and there are no features left out of the free version. The only advantage of the Mac App Store version is that you can get automatic updates. Purchasing the App Store version directly funds the development of UTM and shows your support." I think it relies on macos to check for updates, rather than the UTM.app checking on its own. In any case, the free version currently does not
    As of March 2023, there have been over 90 releases of new versions of UTM, lately more than one a month. So the beta versions may be worth checking out! You can manually download both stable and beta releases at https://github.com/utmapp/UTM/releases such as this 4.20-beta version:
    https://github.com/utmapp/UTM/releases/download/v4.2.0/UTM.dmg (newest beta released as of 2023-Mar-6). If you manually copy the UTM.app from the dmg to /Applications, you'll have to check the releases site to find new releases. Or if you have (home)brew, you can just brew update utm or brew update utm-beta.

  • Get a minimal debian11-xfce, like UTM-provided vm at https://mac.getutm.app/gallery/debian-11-xfce, which is for arm64 (and not for intel amd64/x86) and so best used only on apple-silicon macs (or ios!). (For intel, as of Mar 2023 there was not any amd64/x86 debian-11 UTM bundle in the gallery for intel macs, but I'll try to get one added. A bundle is simply an item whose name ends in .utm such as debian-11.5-xfce-arm64-utm inside https://github.com/utmapp/vm-downloads/releases/download/debian-11.5/debian-11.5-xfce-arm64-utm4.zip And/or I will post post how to create an intel-debian-vm from scratch using appropriate iso from https://www.debian.org/CD/netinst/ which for amd64/x86 is currently https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso file.)

  • Open a terminal In the deb11 vm. For example, right-click on desktop -> Open Terminal here.

  • Optional but nice: create account with same (short) username as on macos host: In vm:

sudo adduser     _mac-user_
sudo passwod   _mac-user_

Be sure you substitute your actual short username on mac for _mac-user_. This way when you ssh/scp to/from vm/mac, you won't have to specify username). In vm, do id debian and id mac-user then add mac-user to appropriate groups:

sudo usermod -a -G examplegroup mac-user
  • In vm: sudo visudo then add lines like:
%admin          ALL = (ALL) ALL
mac-user       ALL = (ALL) ALL
  • Create, copy or download a file in /var/tmp/ called gle-packages.txt with the following contents:
apt-listchanges
atril
bind9-dnsutils
deborphan
discover
dkms
doc-debian
dpkg-repack
featherpad
gle-graphics
ifupdown
init
installation-report
iputils-ping
liblockfile-bin
lightdm
nano
netcat-traditional
nftables
seetxt
task-english
task-laptop
task-ssh-server
telnet
texlive-latex-base
traceroute
usbutils
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        14G  3.7G  8.9G  30% /   # 3.7gb used before install

/dev/sda2        14G  4.1G  8.6G  33% /  #  4.1gb used after install
  • sudo apt-get -y --no-install-recommends install git
    then cd /var/tmp; git clone https://github.com/vlabella/gle-library.git

If on apple-silicon (m1) then
sudo apt-get -y --no-install-recommends install linux-image-arm64
If in intel vm/mac (x86/amd64) then
sudo apt-get -y --no-install-recommends install linux-image-amd64

Now, in terminal type qgle and you should be able to open files in this tree: /var/tmp/gle-library/examples After qgle exports to a pdf, it can optionally automatically open in the viewer. We installed "Atril Document Viewer" which seems to do a good job of displaying pdf. Set that as default app for opening pdfs if need be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment