The answer by @karolus above also provides a solution for LO users who want to write their macro in LibreOffice BASIC.
They could create a .py file which contains a function that returns sys.platform, and invoke that Python function using BASIC.
The following LibreOffice BASIC function returns “linux” for me.
Function get_sys_platform()
REM Returns the output of sys.platform.
REM Trying to find a workaround for the limited GetGUItype() functionality in LibreOffice BASIC.
REM Based on @wertie's idea here: https://ask.libreoffice.org/t/best-macro-to-detect-the-operating-system/13300
REM This only works if the user has a file called "get_os.py" inside the LibreOffice Scripts Folder for Python.
REM ( On Ubuntu this folder is located at: "/home/username/.config/libreoffice/4/user/Scripts/python" )
REM Inside the file "get_os.py" there should be these 5 lines ( without the apostrophes ' at the start ):
'#!/usr/bin/env python3
'def get_OS( ):
' import sys
' return sys.platform
'g_exportedScripts = get_OS,
REM Now the user can call the get_OS() script in BASIC as follows:
Dim oScriptProvider, oScript
Dim aParams(), aOutParamIndex(), aOutParam()
oScriptProvider = ThisComponent.getScriptProvider()
oScript = oScriptProvider.getScript( "vnd.sun.star.script:get_os.py$get_OS?language=Python&location=user" )
get_sys_platform = oScript.invoke( aParams(), aOutParamIndex(), aOutParam() )
End Function