Updates
This commit is contained in:
parent
84ce8b8ade
commit
eed5964b1a
|
@ -1 +1 @@
|
|||
2.7.2
|
||||
2.8BETA
|
174
hypr/apps/ml4w-welcome/ml4w-welcome.py
Normal file
174
hypr/apps/ml4w-welcome/ml4w-welcome.py
Normal file
|
@ -0,0 +1,174 @@
|
|||
# __ __ _ _ ___ __ _ _ _
|
||||
# | \/ | | | || \ \ / / / \ | |__ ___ _ _| |_
|
||||
# | |\/| | | | || |\ \ /\ / / / _ \ | '_ \ / _ \| | | | __|
|
||||
# | | | | |__|__ _\ V V / / ___ \| |_) | (_) | |_| | |_
|
||||
# |_| |_|_____| |_| \_/\_/ /_/ \_\_.__/ \___/ \__,_|\__|
|
||||
|
||||
import sys
|
||||
import gi
|
||||
import subprocess
|
||||
import os
|
||||
import threading
|
||||
|
||||
gi.require_version('Gtk', '4.0')
|
||||
gi.require_version('Adw', '1')
|
||||
|
||||
from gi.repository import Gtk, Adw, Gio
|
||||
from gi.repository import GLib
|
||||
from gi.repository import GObject
|
||||
|
||||
|
||||
# -----------------------------------------
|
||||
# Define UI template
|
||||
# -----------------------------------------
|
||||
@Gtk.Template(filename='src/welcome.ui')
|
||||
|
||||
# -----------------------------------------
|
||||
# Main Window
|
||||
# -----------------------------------------
|
||||
class MainWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = 'Ml4wWelcomeWindow'
|
||||
|
||||
# Get objects from template
|
||||
ml4w_version = Gtk.Template.Child()
|
||||
ml4w_logo = Gtk.Template.Child()
|
||||
update_banner = Gtk.Template.Child()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# -----------------------------------------
|
||||
# Main App
|
||||
# -----------------------------------------
|
||||
class MyApp(Adw.Application):
|
||||
|
||||
# Path to home folder
|
||||
homeFolder = os.path.expanduser('~')
|
||||
current_version_name = ""
|
||||
current_version_code = ""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(application_id='com.ml4w.welcome',
|
||||
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
|
||||
self.create_action('quit', lambda *_: self.quit(), ['<primary>q'])
|
||||
self.create_action('update', self.on_system_update)
|
||||
self.create_action('cleanup', self.on_system_cleanup)
|
||||
self.create_action('about', self.on_about)
|
||||
self.create_action('settings', self.on_settings)
|
||||
self.create_action('waybar_reload', self.on_waybar_reload)
|
||||
self.create_action('keybindings', self.on_keybindings)
|
||||
self.create_action('gitlab', self.on_gitlab)
|
||||
self.create_action('youtube', self.on_youtube)
|
||||
self.create_action('wallpaper', self.on_wallpaper)
|
||||
self.create_action('waybartheme', self.on_waybartheme)
|
||||
self.create_action('howtoupdate', self.on_howtoupdate)
|
||||
|
||||
def do_activate(self):
|
||||
win = self.props.active_window
|
||||
if not win:
|
||||
win = MainWindow(application=self)
|
||||
|
||||
# Set ML4W logo
|
||||
win.ml4w_logo.set_from_file("src/icon.png")
|
||||
|
||||
# Check dotfiles version
|
||||
self.readDotfilesVersion(win)
|
||||
|
||||
# Force dark theme
|
||||
self.changeTheme(win)
|
||||
|
||||
# Check for updates
|
||||
self.checkForUpdates(win)
|
||||
|
||||
# Show Application Window
|
||||
win.present()
|
||||
|
||||
def changeTheme(self,win):
|
||||
app = win.get_application()
|
||||
sm = app.get_style_manager()
|
||||
sm.set_color_scheme(Adw.ColorScheme.PREFER_DARK)
|
||||
|
||||
def checkForUpdates(self,win):
|
||||
try:
|
||||
result = subprocess.run(["bash", self.homeFolder + "/dotfiles/.version/update.sh"], capture_output=True, text=True)
|
||||
web_version = result.stdout.strip()
|
||||
# print("Update " + web_version)
|
||||
|
||||
if (web_version == '0'):
|
||||
# print("Show update banner")
|
||||
win.update_banner.set_revealed(True)
|
||||
except:
|
||||
print("ERROR: Could not read the file /dotfiles/.version/update.sh")
|
||||
|
||||
def readDotfilesVersion(self,win):
|
||||
try:
|
||||
result = subprocess.run(["bash", self.homeFolder + "/dotfiles/.version/version.sh"], capture_output=True, text=True)
|
||||
# print("Version " + result.stdout)
|
||||
version = result.stdout
|
||||
version_arr = version.split(" ")
|
||||
self.current_version_name = version_arr[0]
|
||||
self.current_version_code = version_arr[1]
|
||||
win.ml4w_version.set_text("Version: " + self.current_version_name)
|
||||
except:
|
||||
print("ERROR: Could not read the file /dotfiles/.version/version.sh")
|
||||
win.ml4w_version.set_text("")
|
||||
|
||||
def on_about(self, widget, _):
|
||||
dialog = Adw.AboutWindow(
|
||||
application_icon="application-x-executable",
|
||||
application_name="ML4W Welcome",
|
||||
developer_name="Stephan Raabe",
|
||||
version="1.0.0",
|
||||
website="https://gitlab.com/stephan-raabe/dotfiles",
|
||||
issue_url="https://gitlab.com/stephan-raabe/dotfiles/-/issues",
|
||||
support_url="https://gitlab.com/stephan-raabe/dotfiles/-/issues",
|
||||
copyright="© 2024 Stephan Raabe",
|
||||
license_type=Gtk.License.GPL_3_0_ONLY
|
||||
)
|
||||
dialog.present()
|
||||
|
||||
def on_settings(self, widget, _):
|
||||
subprocess.Popen(["alacritty", "--class", "dotfiles-floating", "-e", self.homeFolder + "/dotfiles/hypr/start-settings.sh"])
|
||||
|
||||
def on_system_update(self, widget, _):
|
||||
subprocess.Popen(["alacritty","-e", self.homeFolder + "/dotfiles/scripts/installupdates.sh"])
|
||||
|
||||
def on_system_cleanup(self, widget, _):
|
||||
subprocess.Popen(["alacritty","-e", self.homeFolder + "/dotfiles/scripts/cleanup.sh"])
|
||||
|
||||
def on_waybar_reload(self, widget, _):
|
||||
subprocess.Popen(["bash", self.homeFolder + "/dotfiles/waybar/launch.sh"])
|
||||
|
||||
def on_keybindings(self, widget, _):
|
||||
subprocess.Popen(["bash", self.homeFolder + "/dotfiles/hypr/scripts/keybindings.sh"])
|
||||
|
||||
def on_gitlab(self, widget, _):
|
||||
subprocess.run(["xdg-open", "https://gitlab.com/stephan-raabe/dotfiles"])
|
||||
|
||||
def on_howtoupdate(self, widget, _):
|
||||
subprocess.run(["xdg-open", "https://gitlab.com/stephan-raabe/dotfiles#update-with-git"])
|
||||
|
||||
def on_youtube(self, widget, _):
|
||||
subprocess.run(["xdg-open", "https://www.youtube.com/channel/UC0sUzmZ0CHvVCVrpRfGKZfw"])
|
||||
|
||||
def on_wallpaper(self, widget, _):
|
||||
subprocess.Popen(["bash", self.homeFolder + "/dotfiles/hypr/scripts/wallpaper.sh","select"])
|
||||
|
||||
def on_waybartheme(self, widget, _):
|
||||
subprocess.Popen(["bash", self.homeFolder + "/dotfiles/waybar/themeswitcher.sh"])
|
||||
|
||||
# Add Application actions
|
||||
def create_action(self, name, callback, shortcuts=None):
|
||||
action = Gio.SimpleAction.new(name, None)
|
||||
action.connect("activate", callback)
|
||||
self.add_action(action)
|
||||
if shortcuts:
|
||||
self.set_accels_for_action(f"app.{name}", shortcuts)
|
||||
|
||||
# -----------------------------------------
|
||||
# Application Start
|
||||
# -----------------------------------------
|
||||
app = MyApp()
|
||||
sm = app.get_style_manager()
|
||||
sm.set_color_scheme(Adw.ColorScheme.PREFER_DARK)
|
||||
app.run(sys.argv)
|
BIN
hypr/apps/ml4w-welcome/src/icon-small.png
Normal file
BIN
hypr/apps/ml4w-welcome/src/icon-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
hypr/apps/ml4w-welcome/src/icon.png
Normal file
BIN
hypr/apps/ml4w-welcome/src/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
257
hypr/apps/ml4w-welcome/src/welcome.ui
Normal file
257
hypr/apps/ml4w-welcome/src/welcome.ui
Normal file
|
@ -0,0 +1,257 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<requires lib="Adw" version="1.0"/>
|
||||
<template class="Ml4wWelcomeWindow" parent="AdwApplicationWindow">
|
||||
|
||||
<property name="title">ML4W Welcome</property>
|
||||
<property name="default-width">700</property>
|
||||
<property name="default-height">600</property>
|
||||
|
||||
<property name="content">
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
|
||||
<!-- Header -->
|
||||
<object class="AdwHeaderBar">
|
||||
|
||||
<child type="start">
|
||||
<object class="GtkMenuButton">
|
||||
<property name="label">Settings</property>
|
||||
<property name="menu-model">maintenance_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="tooltip-text">Main Menu</property>
|
||||
<property name="primary">true</property>
|
||||
<property name="menu-model">window_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
<!-- Header -->
|
||||
</child>
|
||||
|
||||
<property name="content">
|
||||
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">1</property>
|
||||
|
||||
<!-- Update Banner -->
|
||||
<child>
|
||||
<object class="AdwBanner" id="update_banner">
|
||||
<property name="button-label" translatable="true">How to update</property>
|
||||
<property name="title">An update for the dotfiles is available!</property>
|
||||
<property name="revealed">false</property>
|
||||
<property name="action-name">app.howtoupdate</property>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Update Banner -->
|
||||
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="valign">3</property>
|
||||
<property name="halign">3</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<!-- ML4W Logo -->
|
||||
<child>
|
||||
<object class="GtkImage" id="ml4w_logo">
|
||||
<property name="name">logo</property>
|
||||
<property name="pixel-size">150</property>
|
||||
<property name="margin-bottom">30</property>
|
||||
</object>
|
||||
</child>
|
||||
<!-- ML4W Logo -->
|
||||
|
||||
<!-- ML4W Headline -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Welcome to ML4W dotfiles</property>
|
||||
<style>
|
||||
<class name="title-1"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<!-- ML4W Headline -->
|
||||
|
||||
<!-- ML4W Headline -->
|
||||
<child>
|
||||
<object class="GtkLabel" id="ml4w_version">
|
||||
<property name="label">Version</property>
|
||||
<property name="margin-bottom">30</property>
|
||||
</object>
|
||||
</child>
|
||||
<!-- ML4W Headline -->
|
||||
|
||||
<!-- Shortcut Terminal -->
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><SUPER>Return</property>
|
||||
<property name="margin-start">12</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="true">to open the terminal</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Shortcut Terminal -->
|
||||
|
||||
<!-- Shortcut Browser -->
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><SUPER>B</property>
|
||||
<property name="margin-start">12</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="true">to open the browser</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Shortcut Browser -->
|
||||
|
||||
<!-- Shortcut Launcher -->
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl><SUPER>Return</property>
|
||||
<property name="margin-start">12</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="true">to open the application launcher</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Shortcut Launcher -->
|
||||
|
||||
<!-- Shortcut Settings -->
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><SUPER><Ctrl>S</property>
|
||||
<property name="margin-start">12</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="true">to open Hyprland settings script</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Shortcut Settings -->
|
||||
|
||||
<!-- Shortcut Button -->
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="margin-top">30</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="valign">3</property>
|
||||
<property name="halign">3</property>
|
||||
<property name="label">All keybindings</property>
|
||||
<property name="action-name">app.keybindings</property>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Shortcut Buttons -->
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
|
||||
<!-- Menu Main -->
|
||||
<menu id="window_menu">
|
||||
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">ML4W GitLab</attribute>
|
||||
<attribute name="action">app.gitlab</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">ML4W YouTube Channel</attribute>
|
||||
<attribute name="action">app.youtube</attribute>
|
||||
</item>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">About</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Exit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
</item>
|
||||
</section>
|
||||
|
||||
</menu>
|
||||
<!-- Menu Main -->
|
||||
|
||||
<!-- Menu Maintenance -->
|
||||
<menu id="maintenance_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">Update Wallpaper</attribute>
|
||||
<attribute name="action">app.wallpaper</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Change Waybar Theme</attribute>
|
||||
<attribute name="action">app.waybartheme</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">Hyprland Settings</attribute>
|
||||
<attribute name="action">app.settings</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">Update your system</attribute>
|
||||
<attribute name="action">app.update</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Cleanup your system</attribute>
|
||||
<attribute name="action">app.cleanup</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">Reload Waybar</attribute>
|
||||
<attribute name="action">app.waybar_reload</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<!-- Menu Maintenance -->
|
||||
|
||||
</interface>
|
|
@ -4,12 +4,18 @@
|
|||
|
||||
windowrulev2 = float,class:(com.ml4w.welcome)
|
||||
windowrulev2 = size 700 600,class:(com.ml4w.welcome)
|
||||
windowrulev2 = nomaximizerequest,class:(com.ml4w.welcome)
|
||||
windowrulev2 = nofullscreenrequest,class:(com.ml4w.welcome)
|
||||
windowrulev2 = center,class:(com.ml4w.welcome)
|
||||
|
||||
windowrulev2 = float,class:(ml4w-welcome.py)
|
||||
windowrulev2 = size 400 500,class:(ml4w-welcome.py)
|
||||
windowrulev2 = nomaximizerequest,class:(ml4w-welcome.py)
|
||||
windowrulev2 = nofullscreenrequest,class:(ml4w-welcome.py)
|
||||
windowrulev2 = center,class:(ml4w-welcome.py)
|
||||
|
||||
windowrulev2 = float,class:(dotfiles-floating)
|
||||
windowrulev2 = size 1000 800,class:(dotfiles-floating)
|
||||
windowrulev2 = center,class:(dotfiles-floating)
|
||||
windowrulev2 = nomaximizerequest,class:(dotfiles-floating)
|
||||
windowrulev2 = nofullscreenrequest,class:(dotfiles-floating)
|
||||
windowrulev2 = center,class:(dotfiles-floating)
|
||||
|
|
|
@ -58,6 +58,13 @@
|
|||
"separate-outputs": true
|
||||
},
|
||||
|
||||
// ML4W Welcome App
|
||||
"custom/ml4w-welcome": {
|
||||
"on-click": "cd ~/dotfiles/hypr/apps/ml4w-welcome; python ml4w-welcome.py",
|
||||
"format": " ",
|
||||
"tooltip": false
|
||||
},
|
||||
|
||||
// Youtube Subscriber Count
|
||||
"custom/youtube": {
|
||||
"format": " {}",
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
"tray",
|
||||
// END TRAY TOOGLE
|
||||
"custom/exit",
|
||||
"custom/ml4w-welcome",
|
||||
"clock"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
"tray",
|
||||
// END TRAY TOOGLE
|
||||
"custom/exit",
|
||||
"custom/ml4w-welcome",
|
||||
"clock"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -183,6 +183,14 @@ window#waybar.empty #window {
|
|||
margin-right:20px;
|
||||
}
|
||||
|
||||
#custom-ml4w-welcome {
|
||||
margin-right: 15px;
|
||||
background-image: url("../../../hypr/apps/ml4w-welcome/src/icon-small.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
padding-right: 24px;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* Idle Inhibator
|
||||
* ----------------------------------------------------- */
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
"tray",
|
||||
// END TRAY TOOGLE
|
||||
"custom/exit",
|
||||
"custom/ml4w-welcome",
|
||||
"clock"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
"tray",
|
||||
// END TRAY TOOGLE
|
||||
"custom/exit",
|
||||
"custom/ml4w-welcome",
|
||||
"clock"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -184,6 +184,14 @@ window#waybar.empty #window {
|
|||
margin-right:20px;
|
||||
}
|
||||
|
||||
#custom-ml4w-welcome {
|
||||
margin-right: 15px;
|
||||
background-image: url("../../../hypr/apps/ml4w-welcome/src/icon-small.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
padding-right: 24px;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* Idle Inhibator
|
||||
* ----------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue
Block a user