Created
February 17, 2020 20:25
-
-
Save sharethewisdom/e4360268d5351591e8649027e8f9f968 to your computer and use it in GitHub Desktop.
wldesk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Defaults] | |
columns=2 | |
style=wldesk.css | |
wallpaper=wldesk.jpg | |
[Firefox] | |
# icon=/usr/share/icons/hicolor/48x48/apps/firefox.png | |
icon=/usr/share/icons/HighContrast/48x48/apps/firefox.png | |
exec=/usr/bin/firejail --disable-mnt --dns=9.9.9.9 --hostname=host --name=firefox --netfilter /usr/lib/firefox/firefox | |
[Termite] | |
icon=/usr/share/icons/HighContrast/48x48/apps/utilities-terminal.png | |
exec=/usr/bin/termite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.icon { | |
background-color: rgba(250,250,250,.6); | |
border-radius: 15px; | |
border-width: 0px; | |
padding: 0px 20px 10px 20px; | |
} | |
.icon label{ | |
color: #222; | |
font-size: 48px; | |
padding-left: 10px; | |
} | |
.icon:hover { | |
background-color: rgba(220,220,220,1); | |
} | |
.icon:hover label{ | |
color: #222; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os,sys,gi | |
import configparser | |
import shlex, subprocess | |
gi.require_version('Gdk', '3.0') | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gdk as gdk | |
from gi.repository import Gtk as gtk | |
from gi.repository import GdkPixbuf as gdkpixbuf | |
have_display = os.environ.get('WAYLAND_DISPLAY') | |
config = configparser.ConfigParser() | |
config.read(os.path.join(os.path.dirname(sys.argv[0]),'wldesk.conf')) | |
class Window(gtk.Window): | |
def __init__(self): | |
super().__init__(title='wldesk') | |
self.overlay = gtk.Overlay() | |
self.add(self.overlay) | |
self.background = gtk.Image.new_from_file(config['Defaults']['wallpaper']) | |
self.overlay.add(self.background) | |
screen = gdk.Display.get_default().get_default_screen() | |
userstyle = gtk.CssProvider() | |
gtk.StyleContext.add_provider_for_screen( | |
screen, userstyle, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION | |
) | |
userstyle.load_from_path( | |
os.path.join(os.path.dirname(sys.argv[0]),config['Defaults']['style']) | |
) | |
self.grid = gtk.Grid( | |
orientation=gtk.Orientation.VERTICAL, | |
valign = gtk.Align.CENTER, | |
halign = gtk.Align.CENTER, | |
# valign = gtk.Align.FILL, | |
# halign = gtk.Align.FILL, | |
column_homogeneous = 1, | |
column_spacing = 30, | |
row_homogeneous = 1, | |
row_spacing = 20, | |
border_width = 40, | |
# height = 46, | |
) | |
def popen(event,section): | |
print(event) | |
subprocess.Popen(shlex.split(config[section]['exec'])) | |
row=1 | |
column=0 | |
for section in config.sections(): | |
if section != 'Defaults': | |
ico = gtk.Image.new_from_file(config[section]['icon']) | |
b = gtk.Button(label=section) | |
b.get_style_context().add_class("icon") | |
b.set_always_show_image(True) | |
b.set_image(ico) | |
b.connect('clicked', popen, section) | |
if column < int(config['Defaults']['columns']): | |
column+=1 | |
else: | |
column=0 | |
row+=1 | |
self.grid.attach(b, column, row, 1, 1) | |
self.overlay.add_overlay(self.grid) | |
if __name__ == '__main__': | |
if not have_display: | |
print('WAYLAND_DISPLAY is not set') | |
win = Window() | |
win.connect("destroy", gtk.main_quit) | |
win.show_all() | |
gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment