#include ONCE "window9.bi"

function GetCurrentSettingsDisplay() as string export
	
	dim as string sRet , sRetPipe
	
	dim as Long iPos , iPos2
	
	dim as single dValue
	
	dim as Display ptr disp = XOpenDisplay(NULL)
	
	dim as Screen ptr  scrn = DefaultScreenOfDisplay(disp)
	'
	dim as Long iDepth = scrn->root_depth
	'
	XCloseDisplay(disp) 
	
	dim as integer f = FreeFile
	
	Open Pipe "xrandr | grep '*'" For Input As #f
	
	Line Input #f, sRetPipe
	
	Close #f 
	
	sRetPipe = trim (sRetPipe)
	
	iPos = instr( sRetPipe , " ")
	
	sRet = left(sRetPipe , iPos-1) & "x" & iDepth & "x"
	
	iPos = instr( sRetPipe , "*")
	
	iPos2 = instrrev( sRetPipe , " " , iPos )
	
	dValue = val(mid(sRetPipe , iPos2 , iPos - iPos2))
	
	if frac(dValue) >= 0.5 then
		
		sRet &=int(dValue)+1
		
	else
		
		sRet &=int(dValue)
		
	EndIf
	
	return sRet
	
End Function

Function GetWidthDesktop(ByRef setting As String) As Integer Export
	
	Var Pos_=InStr(setting,"x")
	
	function=Val(Mid(setting,1,pos_-1))
	
End Function

Function GetHeightDesktop(ByRef setting As String) As Integer Export
	
	Var Pos_=InStr(setting,"x")
	
	Var Pos1_=InStr(Pos_+1,setting,"x")
	
	Function =Val(Mid(setting,pos_+1,Pos1_-1))
	
End Function

Function GetBitsDesktop(ByRef setting As String) As Integer Export
	
	Var Pos_=InStr(setting,"x")
	
	Var Pos1_=InStr(Pos_+1,setting,"x")
	
	Var Pos2_=InStr(Pos1_+1,setting,"x")
	
	Function = Val(Mid(setting,pos1_+1,Pos2_-1))
	
End Function

Function GetFrequencyDesktop(ByRef setting As String) As Integer Export
	
	Var Pos_=InStr(setting,"x")
	
	Var Pos1_=InStr(Pos_+1,setting,"x")
	
	Var Pos2_=InStr(Pos1_+1,setting,"x")
	
	Function = Val(Mid(setting,pos2_+1))
	
End Function