Skip to content

Instantly share code, notes, and snippets.

@diazvictor
Last active February 11, 2021 14:43
Show Gist options
  • Save diazvictor/885b9556688965bea1095a4a91c3080b to your computer and use it in GitHub Desktop.
Save diazvictor/885b9556688965bea1095a4a91c3080b to your computer and use it in GitHub Desktop.
WindowScreen - How To Set Window To Current Screen Resolution Using LGI (Lua + Gtk)
local lgi = require('lgi')
local Gtk = lgi.require('Gtk', '3.0')
local Gdk = lgi.require('Gdk', '3.0')
--- I collect the value of the screen resolution
-- and I pick up its width and height
local screen = Gdk.Screen:get_default()
local width, height = screen:get_width(), screen:get_height()
-- Creates the window
local window = Gtk.Window {
title = 'Window Screen',
application = self,
default_width = width,
default_height = height,
{
Gtk.Label {
use_markup = true,
label = ('My resolution is: <b>%sx%s</b>'):format(width, height)
}
}
}
function window:on_destroy()
Gtk.main_quit()
end
window:show_all()
Gtk.main()
@Miqueas
Copy link

Miqueas commented Feb 9, 2021

Si 😎

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