From 21cfc8a365a637b90ac3fdcaf8be693c2e3ea24d Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Wed, 7 Jun 2023 23:56:42 +0200 Subject: [PATCH 01/23] match for installed apps; special rule for steam --- src/Managers/Process.vala | 7 +- src/Managers/ProcessManager.vala | 118 ++++++++++++++++++++++++++----- src/Managers/ProcessUtils.vala | 14 ++-- 3 files changed, 113 insertions(+), 26 deletions(-) diff --git a/src/Managers/Process.vala b/src/Managers/Process.vala index e407facc..b75a9573 100644 --- a/src/Managers/Process.vala +++ b/src/Managers/Process.vala @@ -91,8 +91,6 @@ public class Monitor.Process : GLib.Object { username = passwd.pw_name; } - - exists = parse_stat () && read_cmdline (); get_usage (0, 1); } @@ -273,7 +271,10 @@ public class Monitor.Process : GLib.Object { } if (cmdline.length <= 0) { - // was empty, not an error + // if cmdline has 0 length we look into stat file + // useful for kworker processes + command = stat.comm; + return true; } diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 74212bb9..04bfb3b5 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -38,7 +38,7 @@ namespace Monitor { foreach (AppInfo app_info in _apps_info) { string commandline = (app_info.get_commandline ()); - // debug ("%s\n", commandline); + debug ("%s * ", app_info.get_commandline ()); // GLib.DesktopAppInfo? dai = info as GLib.DesktopAppInfo; @@ -174,7 +174,7 @@ namespace Monitor { var uid = Posix.getuid (); GTop.ProcList proclist; - // var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_UID, uid); + // var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_UID, uid); var pids = GTop.get_proclist (out proclist, GTop.GLIBTOP_KERN_PROC_ALL, uid); for (int i = 0; i < proclist.number; i++) { @@ -194,34 +194,116 @@ namespace Monitor { updated (); } - /** - * Parses a pid and adds a Process to our process_list or to the kernel_blacklist - * - * returns the created process - */ - private Process ? add_process (int pid, bool lazy_signal = false) { - // create the process - var process = new Process (pid); + private bool match_process_app (Process process) { + var command_sanitized = ProcessUtils.sanitize_commandline (process.command); + var command_sanitized_basename = Path.get_basename (command_sanitized); - // placeholding shortened commandline - process.application_name = ProcessUtils.sanitize_commandline (process.command); + process.application_name = command_sanitized_basename; - // checking maybe it's an application foreach (var key in apps_info_list.keys) { - if (key.contains (process.application_name)) { + if (apps_info_list.get (key).get_executable () == command_sanitized) { + process.application_name = apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + } else if (apps_info_list.get (key).get_executable () == process.command.split (" ")[1]) { + process.application_name = apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + } else if (key.split (" ")[1] != null) { + if (key.split (" ")[1].contains ("%") || key.split (" ")[1].contains ("--")) { + if (apps_info_list.get (key).get_executable () == command_sanitized_basename) { + process.application_name = apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + return true; + } + } + + // Steam case + // Must match a proper executable and not game executable e.g. steam steam://rungameid/210770 + if ((Path.get_basename (key.split (" ")[0]) == command_sanitized_basename) && !key.split (" ")[1].contains ("steam")) { + process.application_name = apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + return true; + } + } else if (apps_info_list.get (key).get_commandline () == process.command) { process.application_name = apps_info_list.get (key).get_name (); - // debug (apps_info_list.get (key).get_icon ().to_string ()); process.icon = apps_info_list.get (key).get_icon (); } } - if (process.application_name == "bash") { - debug ("app name is [bash] " + process.application_name); + if (ProcessUtils.is_shell (process.command.split (" ")[0])) { process.icon = ProcessUtils.get_bash_icon (); + debug ("app name is " + process.application_name); } - if (process.application_name == "docker" || process.application_name == "dockerd") { + if (command_sanitized_basename == "docker" || command_sanitized_basename == "dockerd" || command_sanitized_basename == "docker-proxy") { process.icon = ProcessUtils.get_docker_icon (); + process.application_name = command_sanitized_basename; + debug ("app name is " + process.application_name); + } + + return true; + } + + /** + * Parses a pid and adds a Process to our `process_list` or to the `kernel_blacklist` + * + * returns the created process + */ + private Process ? add_process (int pid, bool lazy_signal = false) { + // create the process + var process = new Process (pid); + + if (!process.exists) { + return null; } + + this.match_process_app (process); + + // placeholding shortened commandline + // var command_sanitized = ProcessUtils.sanitize_commandline (process.command); + // var command_sanitized_basename = Path.get_basename (command_sanitized); + + // process.application_name = process.command; + + // checking maybe it's an application + // foreach (var key in apps_info_list.keys) { + // var splitted_key = key.split (" "); + // var kkey = ""; + + + // if (splitted_key[1] != null) { + // if (splitted_key[1].contains ("%") || splitted_key[1].contains("--")) { + // kkey = splitted_key[0]; + // } + // } + + //// strict check for exact command without args + // if (kkey == command_sanitized) { + // debug(" For %s", command_sanitized); + // debug(" | Found app1 %s", apps_info_list.get (key).get_commandline ()); + // process.application_name = apps_info_list.get (key).get_name (); + //// debug (apps_info_list.get (key).get_icon ().to_string ()); + // process.icon = apps_info_list.get (key).get_icon (); + + //// check only for executable name + // } else if (ProcessUtils.sanitize_commandline (kkey) == command_sanitized_basename){ + // debug(" For %s", command_sanitized_basename); + // debug(" | Found app2 %s", apps_info_list.get (key).get_commandline ()); + // process.application_name = apps_info_list.get (key).get_name (); + // process.icon = apps_info_list.get (key).get_icon (); + // } else { + //// var splitted_commandline = process.command.split (" "); + //// if (!splitted_commandline[0].contains ("/")){ + //// process.application_name = apps_info_list.get (key).get_name (); + //// process.icon = apps_info_list.get (key).get_icon (); + //// } + + //// process.application_name = process.command; + // } + // } + + + + + if (process.exists) { if (process.stat.pgrp != 0) { // regular process, add it to our cache diff --git a/src/Managers/ProcessUtils.vala b/src/Managers/ProcessUtils.vala index d5b28a7b..6389c6f1 100644 --- a/src/Managers/ProcessUtils.vala +++ b/src/Managers/ProcessUtils.vala @@ -1,25 +1,29 @@ public class Monitor.ProcessUtils { // checks if it is run by shell - private static bool is_shell (string chunk) { + public static bool is_shell (string chunk) { return "sh" == chunk || "bash" == chunk || "zsh" == chunk; } - private static bool is_python (string chunk) { + public static bool is_python (string chunk) { return chunk.contains ("python"); } public static string sanitize_commandline (string ? commandline) { - if (commandline == null) return Path.get_basename (""); + if (commandline == null) return ""; // splitting command; might include many options var splitted_commandline = commandline.split (" "); // check if started by any shell if (is_shell (splitted_commandline[0]) || is_python (splitted_commandline[0]) ) { - return Path.get_basename (splitted_commandline[1]); + return commandline; } - return Path.get_basename (splitted_commandline[0]); + // if (!splitted_commandline[0].contains ("/")) { + // return commandline; + // } + + return splitted_commandline[0]; } public static string ? read_file (string path) { From d37333b48b60540ff5efce7b783aafc1219e101b Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Fri, 16 Jun 2023 13:59:38 +0200 Subject: [PATCH 02/23] Some POC of finding flatpak apps --- meson.build | 1 + src/Managers/ProcessManager.vala | 96 ++--- subprojects/live-chart | 2 +- vapi/flatpak.vapi | 583 +++++++++++++++++++++++++++++++ 4 files changed, 633 insertions(+), 49 deletions(-) create mode 100644 vapi/flatpak.vapi diff --git a/meson.build b/meson.build index c17bb40d..d9c2b993 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,7 @@ app_dependencies = [ dependency('x11'), dependency('udisks2'), dependency('json-glib-1.0'), + dependency('flatpak'), livechart_proj.get_variable('livechart_dep'), diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 04bfb3b5..97d08d42 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -16,6 +16,8 @@ namespace Monitor { private Gee.TreeMap process_list; private Gee.HashSet kernel_process_blacklist; private Gee.HashMap apps_info_list; + private Gee.HashSet flatpak_apps = new Gee.HashSet (); + public signal void process_added (Process process); @@ -29,6 +31,9 @@ namespace Monitor { apps_info_list = new Gee.HashMap (); populate_apps_info (); + Flatpak.Instance.get_all ().foreach ((fp) => { + flatpak_apps.add (fp); + }); update_processes.begin (); } @@ -38,7 +43,9 @@ namespace Monitor { foreach (AppInfo app_info in _apps_info) { string commandline = (app_info.get_commandline ()); - debug ("%s * ", app_info.get_commandline ()); + // debug ("%s * ", app_info.get_commandline ()); + + // GLib.DesktopAppInfo? dai = info as GLib.DesktopAppInfo; @@ -55,6 +62,17 @@ namespace Monitor { // sanitize_cmd (ref cmd); apps_info_list.set (commandline, app_info); } + + var running_flatpaks = Flatpak.Instance.get_all (); + + running_flatpaks.foreach ((fp) => { + debug ("----------<><> %s bwrap: %d app: %d", fp.get_app (), fp.get_pid(), fp.get_child_pid ()); + // debug ("%s ", fp.get_info().to_data()); + }); + + // debug ("----------<><> %s", running_flatpaks[0]); + + } // private static void sanitize_cmd(ref string? commandline) { @@ -190,8 +208,14 @@ namespace Monitor { cpu_last_useds = useds; cpu_last_totals = cpu_data.xcpu_total; + + Flatpak.Instance.get_all ().foreach ((fp) => { + flatpak_apps.add (fp); + }); + /* emit the updated signal so that subscribers can update */ updated (); + } private bool match_process_app (Process process) { @@ -200,6 +224,22 @@ namespace Monitor { process.application_name = command_sanitized_basename; + foreach (var flatpak_app in flatpak_apps) { + + if (flatpak_app.get_pid () == process.stat.pid) { + debug ("###### ##Found Flatpak app: %s ", flatpak_app.get_app ()); + // @TODO need to find a appinfo for this app + // @TODO probably need to change the way in which appinfos are stored + foreach (var key in apps_info_list.keys) { + if (apps_info_list.get (key).get_id ().replace (".desktop", "") == flatpak_app.get_app ()) { + debug ("%s %s", apps_info_list.get (key).get_id (), flatpak_app.get_app ()); + process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + } + } + } + } + foreach (var key in apps_info_list.keys) { if (apps_info_list.get (key).get_executable () == command_sanitized) { process.application_name = apps_info_list.get (key).get_name (); @@ -257,53 +297,6 @@ namespace Monitor { this.match_process_app (process); - // placeholding shortened commandline - // var command_sanitized = ProcessUtils.sanitize_commandline (process.command); - // var command_sanitized_basename = Path.get_basename (command_sanitized); - - // process.application_name = process.command; - - // checking maybe it's an application - // foreach (var key in apps_info_list.keys) { - // var splitted_key = key.split (" "); - // var kkey = ""; - - - // if (splitted_key[1] != null) { - // if (splitted_key[1].contains ("%") || splitted_key[1].contains("--")) { - // kkey = splitted_key[0]; - // } - // } - - //// strict check for exact command without args - // if (kkey == command_sanitized) { - // debug(" For %s", command_sanitized); - // debug(" | Found app1 %s", apps_info_list.get (key).get_commandline ()); - // process.application_name = apps_info_list.get (key).get_name (); - //// debug (apps_info_list.get (key).get_icon ().to_string ()); - // process.icon = apps_info_list.get (key).get_icon (); - - //// check only for executable name - // } else if (ProcessUtils.sanitize_commandline (kkey) == command_sanitized_basename){ - // debug(" For %s", command_sanitized_basename); - // debug(" | Found app2 %s", apps_info_list.get (key).get_commandline ()); - // process.application_name = apps_info_list.get (key).get_name (); - // process.icon = apps_info_list.get (key).get_icon (); - // } else { - //// var splitted_commandline = process.command.split (" "); - //// if (!splitted_commandline[0].contains ("/")){ - //// process.application_name = apps_info_list.get (key).get_name (); - //// process.icon = apps_info_list.get (key).get_icon (); - //// } - - //// process.application_name = process.command; - // } - // } - - - - - if (process.exists) { if (process.stat.pgrp != 0) { // regular process, add it to our cache @@ -332,6 +325,13 @@ namespace Monitor { private void remove_process (int pid) { if (process_list.has_key (pid)) { process_list.unset (pid); + // flatpak_apps.remove (pid); + foreach (var fp in flatpak_apps) { + if (fp.get_pid () == pid) { + flatpak_apps.remove (fp); + break; + } + } process_removed (pid); } else if (kernel_process_blacklist.contains (pid)) { kernel_process_blacklist.remove (pid); diff --git a/subprojects/live-chart b/subprojects/live-chart index 5f8ddce7..1c090e18 160000 --- a/subprojects/live-chart +++ b/subprojects/live-chart @@ -1 +1 @@ -Subproject commit 5f8ddce715f6a9130955bc5f08437050265a317c +Subproject commit 1c090e18fa4ae9f3ccfe0f38d619ebeccd7d6361 diff --git a/vapi/flatpak.vapi b/vapi/flatpak.vapi new file mode 100644 index 00000000..cdd73020 --- /dev/null +++ b/vapi/flatpak.vapi @@ -0,0 +1,583 @@ +/* flatpak.vapi generated by vapigen, do not modify. */ + +[CCode (cprefix = "Flatpak", gir_namespace = "Flatpak", gir_version = "1.0", lower_case_cprefix = "flatpak_")] +namespace Flatpak { + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_bundle_ref_get_type ()")] + public class BundleRef : Flatpak.Ref { + [CCode (has_construct_function = false)] + public BundleRef (GLib.File file) throws GLib.Error; + public GLib.Bytes get_appstream (); + public GLib.File get_file (); + public GLib.Bytes get_icon (int size); + public uint64 get_installed_size (); + public GLib.Bytes get_metadata (); + public string get_origin (); + [Version (since = "0.8.0")] + public string get_runtime_repo_url (); + public GLib.File file { owned get; construct; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_installation_get_type ()")] + public class Installation : GLib.Object { + [CCode (has_construct_function = false)] + protected Installation (); + [Version (since = "1.3.4")] + public bool add_remote (Flatpak.Remote remote, bool if_needed, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.10.0")] + public bool cleanup_local_refs_sync (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.FileMonitor create_monitor (GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool drop_caches (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.Bytes fetch_remote_metadata_sync (string remote_name, Flatpak.Ref @ref, GLib.Cancellable? cancellable = null) throws GLib.Error; + public Flatpak.RemoteRef fetch_remote_ref_sync (string remote_name, Flatpak.RefKind kind, string name, string? arch, string? branch, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.3.3")] + public Flatpak.RemoteRef fetch_remote_ref_sync_full (string remote_name, Flatpak.RefKind kind, string name, string? arch, string? branch, Flatpak.QueryFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool fetch_remote_size_sync (string remote_name, Flatpak.Ref @ref, out uint64 download_size, out uint64 installed_size, GLib.Cancellable? cancellable = null) throws GLib.Error; + [CCode (has_construct_function = false)] + public Installation.for_path (GLib.File path, bool user, GLib.Cancellable? cancellable = null) throws GLib.Error; + public string get_config (string key, GLib.Cancellable? cancellable = null) throws GLib.Error; + public Flatpak.InstalledRef get_current_installed_app (string name, GLib.Cancellable? cancellable = null) throws GLib.Error; + [CCode (array_length = false, array_null_terminated = true)] + [Version (since = "1.5.0")] + public string[] get_default_languages () throws GLib.Error; + [CCode (array_length = false, array_null_terminated = true)] + [Version (since = "1.5.1")] + public string[] get_default_locales () throws GLib.Error; + [Version (since = "0.8")] + public unowned string get_display_name (); + [Version (since = "0.8")] + public unowned string get_id (); + public Flatpak.InstalledRef get_installed_ref (Flatpak.RefKind kind, string name, string? arch, string? branch, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool get_is_user (); + [Version (since = "1.1")] + public bool get_min_free_space_bytes (out uint64 out_bytes) throws GLib.Error; + [Version (since = "1.1.1")] + public bool get_no_interaction (); + public GLib.File get_path (); + [Version (since = "0.8")] + public int get_priority (); + public Flatpak.Remote get_remote_by_name (string name, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.8")] + public Flatpak.StorageType get_storage_type (); + [Version (deprecated = true, deprecated_since = "1.7.0")] + public Flatpak.InstalledRef install (string remote_name, Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (delegate_target_pos = 6.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0")] + public Flatpak.InstalledRef install_bundle (GLib.File file, [CCode (delegate_target_pos = 2.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0")] + public Flatpak.InstalledRef install_full (Flatpak.InstallFlags flags, string remote_name, Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (array_length = false, array_null_terminated = true)] string[]? subpaths, [CCode (delegate_target_pos = 8.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0", since = "0.6.10")] + public Flatpak.RemoteRef install_ref_file (GLib.Bytes ref_file_data, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool launch (string name, string? arch, string? branch, string? commit, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.1")] + public bool launch_full (Flatpak.LaunchFlags flags, string name, string? arch, string? branch, string? commit, Flatpak.Instance? instance_out, GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_installed_refs (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_installed_refs_by_kind (Flatpak.RefKind kind, GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_installed_refs_for_update (GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.6.7")] + public GLib.GenericArray list_installed_related_refs_sync (string remote_name, string @ref, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.9.1")] + public GLib.GenericArray list_pinned_refs (string? arch, GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_remote_refs_sync (string remote_or_uri, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.3.3")] + public GLib.GenericArray list_remote_refs_sync_full (string remote_or_uri, Flatpak.QueryFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.11.1")] + public GLib.GenericArray list_remote_related_refs_for_installed_sync (string remote_name, string @ref, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.6.7")] + public GLib.GenericArray list_remote_related_refs_sync (string remote_name, string @ref, GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_remotes (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.GenericArray list_remotes_by_type ([CCode (array_length_cname = "num_types", array_length_pos = 1.5, array_length_type = "gsize")] Flatpak.RemoteType[] types, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.1.2")] + public GLib.GenericArray list_unused_refs (string? arch, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.9.1")] + public GLib.GenericArray list_unused_refs_with_options (string? arch, GLib.HashTable? metadata_injection, GLib.Variant? options, GLib.Cancellable? cancellable = null) throws GLib.Error; + public string load_app_overrides (string app_id, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool modify_remote (Flatpak.Remote remote, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.10.0")] + public bool prune_local_repo (GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.10.0")] + public bool remove_local_ref_sync (string remote_name, string @ref, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool remove_remote (string name, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.0.3")] + public bool run_triggers (GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool set_config_sync (string key, string value, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "1.1.1")] + public void set_no_interaction (bool no_interaction); + [CCode (has_construct_function = false)] + public Installation.system (GLib.Cancellable? cancellable = null) throws GLib.Error; + [CCode (has_construct_function = false)] + [Version (since = "0.8")] + public Installation.system_with_id (string? id, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0")] + public bool uninstall (Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (delegate_target_pos = 5.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0", since = "0.11.8")] + public bool uninstall_full (Flatpak.UninstallFlags flags, Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (delegate_target_pos = 6.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0")] + public Flatpak.InstalledRef update (Flatpak.UpdateFlags flags, Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (delegate_target_pos = 6.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool update_appstream_full_sync (string remote_name, string? arch, [CCode (delegate_target_pos = 3.5)] Flatpak.ProgressCallback? progress, bool? out_changed, GLib.Cancellable? cancellable = null) throws GLib.Error; + public bool update_appstream_sync (string remote_name, string? arch, bool? out_changed, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (deprecated = true, deprecated_since = "1.7.0")] + public Flatpak.InstalledRef update_full (Flatpak.UpdateFlags flags, Flatpak.RefKind kind, string name, string? arch, string? branch, [CCode (array_length = false, array_null_terminated = true)] string[]? subpaths, [CCode (delegate_target_pos = 7.5)] Flatpak.ProgressCallback? progress, GLib.Cancellable? cancellable = null) throws GLib.Error; + [Version (since = "0.6.13")] + public bool update_remote_sync (string name, GLib.Cancellable? cancellable = null) throws GLib.Error; + [CCode (has_construct_function = false)] + public Installation.user (GLib.Cancellable? cancellable = null) throws GLib.Error; + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_installed_ref_get_type ()")] + public class InstalledRef : Flatpak.Ref { + [CCode (has_construct_function = false)] + protected InstalledRef (); + [Version (since = "1.4.2")] + public unowned GLib.HashTable? get_appdata_content_rating (); + [Version (since = "1.4.2")] + public unowned string? get_appdata_content_rating_type (); + [Version (since = "1.1.2")] + public unowned string get_appdata_license (); + [Version (since = "1.1.2")] + public unowned string get_appdata_name (); + [Version (since = "1.1.2")] + public unowned string get_appdata_summary (); + [Version (since = "1.1.2")] + public unowned string get_appdata_version (); + public unowned string get_deploy_dir (); + public unowned string get_eol (); + public unowned string get_eol_rebase (); + public uint64 get_installed_size (); + public bool get_is_current (); + public unowned string? get_latest_commit (); + public unowned string get_origin (); + [CCode (array_length = false, array_null_terminated = true)] + public unowned string[] get_subpaths (); + [Version (since = "1.1.2")] + public GLib.Bytes load_appdata (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.Bytes load_metadata (GLib.Cancellable? cancellable = null) throws GLib.Error; + public GLib.HashTable appdata_content_rating { get; construct; } + public string appdata_content_rating_type { get; construct; } + public string appdata_license { get; construct; } + public string appdata_name { get; construct; } + public string appdata_summary { get; construct; } + public string appdata_version { get; construct; } + [NoAccessorMethod] + public string deploy_dir { owned get; set; } + [NoAccessorMethod] + public string end_of_life { owned get; construct; } + [NoAccessorMethod] + public string end_of_life_rebase { owned get; construct; } + [NoAccessorMethod] + public uint64 installed_size { get; set; } + [NoAccessorMethod] + public bool is_current { get; set; } + [NoAccessorMethod] + public string latest_commit { owned get; set; } + [NoAccessorMethod] + public string origin { owned get; set; } + [CCode (array_length = false, array_null_terminated = true)] + [NoAccessorMethod] + public string[] subpaths { owned get; set; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_instance_get_type ()")] + public class Instance : GLib.Object { + [CCode (has_construct_function = false)] + protected Instance (); + [Version (since = "1.1")] + public static GLib.GenericArray get_all (); + [Version (since = "1.1")] + public unowned string? get_app (); + [Version (since = "1.1")] + public unowned string get_arch (); + [Version (since = "1.1")] + public unowned string get_branch (); + [Version (since = "1.1")] + public int get_child_pid (); + [Version (since = "1.1")] + public unowned string get_commit (); + [Version (since = "1.1")] + public unowned string get_id (); + [Version (since = "1.1")] + public GLib.KeyFile get_info (); + [Version (since = "1.1")] + public int get_pid (); + [Version (since = "1.1")] + public unowned string get_runtime (); + [Version (since = "1.1")] + public unowned string get_runtime_commit (); + public bool is_running (); + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_ref_get_type ()")] + public class Ref : GLib.Object { + [CCode (has_construct_function = false)] + protected Ref (); + public string format_ref (); + [Version (since = "1.9.1")] + public unowned string format_ref_cached (); + public unowned string get_arch (); + public unowned string get_branch (); + public unowned string get_collection_id (); + public unowned string get_commit (); + public Flatpak.RefKind get_kind (); + public unowned string get_name (); + public static Flatpak.Ref parse (string @ref) throws GLib.Error; + public string arch { get; construct; } + public string branch { get; construct; } + public string collection_id { get; construct; } + public string commit { get; construct; } + public Flatpak.RefKind kind { get; construct; } + public string name { get; construct; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_related_ref_get_type ()")] + public class RelatedRef : Flatpak.Ref { + [CCode (has_construct_function = false)] + protected RelatedRef (); + [CCode (array_length = false, array_null_terminated = true)] + [Version (since = "0.6.7")] + public unowned string[] get_subpaths (); + [NoAccessorMethod] + public bool should_autoprune { get; construct; } + [NoAccessorMethod] + public bool should_delete { get; construct; } + [NoAccessorMethod] + public bool should_download { get; construct; } + [CCode (array_length = false, array_null_terminated = true)] + public string[] subpaths { get; construct; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_remote_get_type ()")] + public class Remote : GLib.Object { + [CCode (has_construct_function = false)] + public Remote (string name); + [CCode (has_construct_function = false)] + [Version (since = "1.3.4")] + public Remote.from_file (string name, GLib.Bytes data) throws GLib.Error; + public GLib.File get_appstream_dir (string? arch); + public GLib.File get_appstream_timestamp (string? arch); + public string? get_collection_id (); + [Version (since = "1.4")] + public string get_comment (); + [Version (since = "0.6.12")] + public string get_default_branch (); + [Version (since = "1.4")] + public string get_description (); + public bool get_disabled (); + [Version (since = "1.4")] + public string get_filter (); + public bool get_gpg_verify (); + [Version (since = "1.4")] + public string get_homepage (); + [Version (since = "1.4")] + public string get_icon (); + [Version (since = "1.1.1")] + public string get_main_ref (); + public unowned string get_name (); + public bool get_nodeps (); + public bool get_noenumerate (); + public int get_prio (); + [Version (since = "0.9.8")] + public Flatpak.RemoteType get_remote_type (); + public string get_title (); + public string get_url (); + public void set_collection_id (string? collection_id); + [Version (since = "1.4")] + public void set_comment (string comment); + [Version (since = "0.6.12")] + public void set_default_branch (string default_branch); + [Version (since = "1.4")] + public void set_description (string description); + public void set_disabled (bool disabled); + [Version (since = "1.4")] + public void set_filter (string filter_path); + public void set_gpg_key (GLib.Bytes gpg_key); + public void set_gpg_verify (bool gpg_verify); + [Version (since = "1.4")] + public void set_homepage (string homepage); + [Version (since = "1.4")] + public void set_icon (string icon); + [Version (since = "1.1.1")] + public void set_main_ref (string main_ref); + public void set_nodeps (bool nodeps); + public void set_noenumerate (bool noenumerate); + public void set_prio (int prio); + public void set_title (string title); + public void set_url (string url); + [NoAccessorMethod] + public string name { owned get; set; } + [NoAccessorMethod] + [Version (since = "0.9.8")] + public Flatpak.RemoteType type { get; construct; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_remote_ref_get_type ()")] + public class RemoteRef : Flatpak.Ref { + [CCode (has_construct_function = false)] + protected RemoteRef (); + public uint64 get_download_size (); + public unowned string get_eol (); + public unowned string get_eol_rebase (); + public uint64 get_installed_size (); + public unowned GLib.Bytes? get_metadata (); + public unowned string get_remote_name (); + public uint64 download_size { get; construct; } + [NoAccessorMethod] + public string end_of_life { owned get; construct; } + [NoAccessorMethod] + public string end_of_life_rebase { owned get; construct; } + public uint64 installed_size { get; construct; } + public GLib.Bytes metadata { get; construct; } + public string remote_name { get; construct; } + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_transaction_get_type ()")] + public class Transaction : GLib.Object, GLib.Initable { + [CCode (has_construct_function = false)] + protected Transaction (); + [Version (since = "1.5.1")] + public void abort_webflow (uint id); + public void add_default_dependency_sources (); + public void add_dependency_source (Flatpak.Installation installation); + public bool add_install (string remote, string @ref, [CCode (array_length = false, array_null_terminated = true)] string[]? subpaths) throws GLib.Error; + public bool add_install_bundle (GLib.File file, GLib.Bytes? gpg_data) throws GLib.Error; + public bool add_install_flatpakref (GLib.Bytes flatpakref_data) throws GLib.Error; + [Version (since = "1.3.3.")] + public bool add_rebase (string remote, string @ref, string? subpaths, [CCode (array_length = false, array_null_terminated = true)] string[]? previous_ids) throws GLib.Error; + [Version (since = "1.7.1")] + public void add_sideload_repo (string path); + public bool add_uninstall (string @ref) throws GLib.Error; + public bool add_update (string @ref, [CCode (array_length = false, array_null_terminated = true)] string[]? subpaths, string? commit) throws GLib.Error; + [Version (since = "1.5.2")] + public void complete_basic_auth (uint id, string user, string password, GLib.Variant options); + [CCode (has_construct_function = false)] + public Transaction.for_installation (Flatpak.Installation installation, GLib.Cancellable? cancellable = null) throws GLib.Error; + public Flatpak.TransactionOperation get_current_operation (); + [Version (since = "1.9.1")] + public bool get_include_unused_uninstall_ops (); + public Flatpak.Installation get_installation (); + [Version (since = "1.5.1")] + public bool get_no_deploy (); + [Version (since = "1.5.1")] + public bool get_no_pull (); + public GLib.List get_operations (); + [Version (since = "1.5.1")] + public unowned string get_parent_window (); + public bool is_empty (); + public virtual bool run (GLib.Cancellable? cancellable = null) throws GLib.Error; + public void set_default_arch (string arch); + [Version (since = "1.9.1")] + public void set_disable_auto_pin (bool disable_pin); + public void set_disable_dependencies (bool disable_dependencies); + public void set_disable_prune (bool disable_prune); + public void set_disable_related (bool disable_related); + public void set_disable_static_deltas (bool disable_static_deltas); + public void set_force_uninstall (bool force_uninstall); + [Version (since = "1.9.1")] + public void set_include_unused_uninstall_ops (bool include_unused_uninstall_ops); + public void set_no_deploy (bool no_deploy); + [Version (since = "1.7.3")] + public void set_no_interaction (bool no_interaction); + public void set_no_pull (bool no_pull); + [Version (since = "1.5.1")] + public void set_parent_window (string parent_window); + public void set_reinstall (bool reinstall); + public Flatpak.Installation installation { owned get; construct; } + public virtual signal bool add_new_remote (Flatpak.TransactionRemoteReason reason, string from_id, string remote_name, string url); + [Version (since = "1.5.2")] + public virtual signal bool basic_auth_start (string remote, string realm, GLib.Variant options, int id); + public virtual signal int choose_remote_for_ref (string for_ref, string runtime_ref, [CCode (array_length = false, array_null_terminated = true)] string[] remotes); + public virtual signal void end_of_lifed (string @ref, string reason, string rebase); + [Version (since = "1.3.2")] + public virtual signal bool end_of_lifed_with_rebase (string remote, string @ref, string reason, string rebased_to_ref, [CCode (array_length = false, array_null_terminated = true)] string[] previous_ids); + [Version (since = "1.8.0")] + public virtual signal void install_authenticator (string remote, string authenticator_ref); + public virtual signal void new_operation (Flatpak.TransactionOperation operation, Flatpak.TransactionProgress progress); + public virtual signal void operation_done (Flatpak.TransactionOperation operation, string? commit, Flatpak.TransactionResult details); + public virtual signal bool operation_error (Flatpak.TransactionOperation operation, GLib.Error error, Flatpak.TransactionErrorDetails detail); + public virtual signal bool ready (); + [Version (since = "1.9.1")] + public virtual signal bool ready_pre_auth (); + [Version (since = "1.5.1")] + public virtual signal void webflow_done (GLib.Variant options, int id); + [Version (since = "1.5.1")] + public virtual signal bool webflow_start (string remote, string url, GLib.Variant options, int id); + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_transaction_operation_get_type ()")] + public class TransactionOperation : GLib.Object { + [CCode (has_construct_function = false)] + protected TransactionOperation (); + public unowned GLib.File get_bundle_path (); + public unowned string get_commit (); + [Version (since = "1.1.2")] + public uint64 get_download_size (); + [Version (since = "1.1.2")] + public uint64 get_installed_size (); + [Version (since = "1.7.3")] + public bool get_is_skipped (); + public unowned GLib.KeyFile get_metadata (); + public unowned GLib.KeyFile get_old_metadata (); + public Flatpak.TransactionOperationType get_operation_type (); + public unowned string get_ref (); + [Version (since = "1.7.3")] + public unowned GLib.GenericArray? get_related_to_ops (); + public unowned string get_remote (); + [Version (since = "1.9.1")] + public bool get_requires_authentication (); + [CCode (array_length = false, array_null_terminated = true)] + [Version (since = "1.9.1")] + public unowned string[] get_subpaths (); + } + [CCode (cheader_filename = "flatpak.h", type_id = "flatpak_transaction_progress_get_type ()")] + public class TransactionProgress : GLib.Object { + [CCode (has_construct_function = false)] + protected TransactionProgress (); + [Version (since = "1.1.2")] + public uint64 get_bytes_transferred (); + public bool get_is_estimating (); + public int get_progress (); + [Version (since = "1.1.2")] + public uint64 get_start_time (); + public string get_status (); + public void set_update_frequency (uint update_interval); + public signal void changed (); + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_INSTALL_FLAGS_", type_id = "flatpak_install_flags_get_type ()")] + [Flags] + public enum InstallFlags { + NONE, + NO_STATIC_DELTAS, + NO_DEPLOY, + NO_PULL, + NO_TRIGGERS + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_LAUNCH_FLAGS_", type_id = "flatpak_launch_flags_get_type ()")] + [Flags] + public enum LaunchFlags { + NONE, + DO_NOT_REAP + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_QUERY_FLAGS_", type_id = "flatpak_query_flags_get_type ()")] + [Flags] + [Version (since = "1.3.3")] + public enum QueryFlags { + NONE, + ONLY_CACHED, + ONLY_SIDELOADED, + ALL_ARCHES + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_REF_KIND_", type_id = "flatpak_ref_kind_get_type ()")] + public enum RefKind { + APP, + RUNTIME + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_REMOTE_TYPE_", type_id = "flatpak_remote_type_get_type ()")] + public enum RemoteType { + STATIC, + USB, + LAN + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_STORAGE_TYPE_", type_id = "flatpak_storage_type_get_type ()")] + [Version (since = "0.6.15")] + public enum StorageType { + DEFAULT, + HARD_DISK, + SDCARD, + MMC, + NETWORK + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_TRANSACTION_ERROR_DETAILS_", type_id = "flatpak_transaction_error_details_get_type ()")] + [Flags] + public enum TransactionErrorDetails { + NON_FATAL + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_TRANSACTION_OPERATION_", type_id = "flatpak_transaction_operation_type_get_type ()")] + public enum TransactionOperationType { + INSTALL, + UPDATE, + INSTALL_BUNDLE, + UNINSTALL, + LAST_TYPE; + public unowned string to_string (); + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_TRANSACTION_REMOTE_", type_id = "flatpak_transaction_remote_reason_get_type ()")] + public enum TransactionRemoteReason { + GENERIC_REPO, + RUNTIME_DEPS + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_TRANSACTION_RESULT_NO_", type_id = "flatpak_transaction_result_get_type ()")] + [Flags] + public enum TransactionResult { + CHANGE + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_UNINSTALL_FLAGS_", type_id = "flatpak_uninstall_flags_get_type ()")] + [Flags] + [Version (since = "0.11.8")] + public enum UninstallFlags { + NONE, + NO_PRUNE, + NO_TRIGGERS + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_UPDATE_FLAGS_", type_id = "flatpak_update_flags_get_type ()")] + [Flags] + public enum UpdateFlags { + NONE, + NO_DEPLOY, + NO_PULL, + NO_STATIC_DELTAS, + NO_PRUNE, + NO_TRIGGERS + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_ERROR_", type_id = "flatpak_error_get_type ()")] + public errordomain Error { + ALREADY_INSTALLED, + NOT_INSTALLED, + ONLY_PULLED, + DIFFERENT_REMOTE, + ABORTED, + SKIPPED, + NEED_NEW_FLATPAK, + REMOTE_NOT_FOUND, + RUNTIME_NOT_FOUND, + DOWNGRADE, + INVALID_REF, + INVALID_DATA, + UNTRUSTED, + SETUP_FAILED, + EXPORT_FAILED, + REMOTE_USED, + RUNTIME_USED, + INVALID_NAME, + OUT_OF_SPACE, + WRONG_USER, + NOT_CACHED, + REF_NOT_FOUND, + PERMISSION_DENIED, + AUTHENTICATION_FAILED, + NOT_AUTHORIZED; + public static GLib.Quark quark (); + } + [CCode (cheader_filename = "flatpak.h", cprefix = "FLATPAK_PORTAL_ERROR_", type_id = "flatpak_portal_error_get_type ()")] + public errordomain PortalError { + FAILED, + INVALID_ARGUMENT, + NOT_FOUND, + EXISTS, + NOT_ALLOWED, + CANCELLED, + WINDOW_DESTROYED; + public static GLib.Quark quark (); + } + [CCode (cheader_filename = "flatpak.h", instance_pos = 3.9)] + public delegate void ProgressCallback (string status, uint progress, bool estimating); + [CCode (cheader_filename = "flatpak.h", cname = "FLATPAK_MAJOR_VERSION")] + public const int MAJOR_VERSION; + [CCode (cheader_filename = "flatpak.h", cname = "FLATPAK_MICRO_VERSION")] + public const int MICRO_VERSION; + [CCode (cheader_filename = "flatpak.h", cname = "FLATPAK_MINOR_VERSION")] + public const int MINOR_VERSION; + [CCode (cheader_filename = "flatpak.h")] + [Version (replacement = "Error.quark")] + public static GLib.Quark error_quark (); + [CCode (cheader_filename = "flatpak.h")] + public static unowned string get_default_arch (); + [CCode (array_length = false, array_null_terminated = true, cheader_filename = "flatpak.h")] + public static unowned string[] get_supported_arches (); + [CCode (cheader_filename = "flatpak.h")] + [Version (since = "0.8")] + public static GLib.GenericArray get_system_installations (GLib.Cancellable? cancellable = null) throws GLib.Error; + [CCode (cheader_filename = "flatpak.h")] + [Version (replacement = "PortalError.quark")] + public static GLib.Quark portal_error_quark (); + [CCode (cheader_filename = "flatpak.h")] + [Version (replacement = "TransactionOperationType.to_string")] + public static unowned string transaction_operation_type_to_string (Flatpak.TransactionOperationType kind); +} From c0f32452c40b233e9f9629b3161a4746bddb5efd Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sat, 17 Jun 2023 21:50:47 +0200 Subject: [PATCH 03/23] Add loose matching for Flatpaks --- src/Managers/ProcessManager.vala | 60 ++++++-------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 04bfb3b5..b397b3c1 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -215,7 +215,6 @@ namespace Monitor { return true; } } - // Steam case // Must match a proper executable and not game executable e.g. steam steam://rungameid/210770 if ((Path.get_basename (key.split (" ")[0]) == command_sanitized_basename) && !key.split (" ")[1].contains ("steam")) { @@ -223,13 +222,21 @@ namespace Monitor { process.icon = apps_info_list.get (key).get_icon (); return true; } + + // workaround for some flatpak apps + if (process.command.contains (apps_info_list.get (key).get_id ().replace (".desktop", ""))) { + process.application_name = apps_info_list.get (key).get_name (); + process.icon = apps_info_list.get (key).get_icon (); + return true; + } } else if (apps_info_list.get (key).get_commandline () == process.command) { process.application_name = apps_info_list.get (key).get_name (); process.icon = apps_info_list.get (key).get_icon (); + return true; } } - if (ProcessUtils.is_shell (process.command.split (" ")[0])) { + if (ProcessUtils.is_shell (command_sanitized_basename)) { process.icon = ProcessUtils.get_bash_icon (); debug ("app name is " + process.application_name); } @@ -239,6 +246,8 @@ namespace Monitor { debug ("app name is " + process.application_name); } + // process.application_name = process.command; + return true; } @@ -257,53 +266,6 @@ namespace Monitor { this.match_process_app (process); - // placeholding shortened commandline - // var command_sanitized = ProcessUtils.sanitize_commandline (process.command); - // var command_sanitized_basename = Path.get_basename (command_sanitized); - - // process.application_name = process.command; - - // checking maybe it's an application - // foreach (var key in apps_info_list.keys) { - // var splitted_key = key.split (" "); - // var kkey = ""; - - - // if (splitted_key[1] != null) { - // if (splitted_key[1].contains ("%") || splitted_key[1].contains("--")) { - // kkey = splitted_key[0]; - // } - // } - - //// strict check for exact command without args - // if (kkey == command_sanitized) { - // debug(" For %s", command_sanitized); - // debug(" | Found app1 %s", apps_info_list.get (key).get_commandline ()); - // process.application_name = apps_info_list.get (key).get_name (); - //// debug (apps_info_list.get (key).get_icon ().to_string ()); - // process.icon = apps_info_list.get (key).get_icon (); - - //// check only for executable name - // } else if (ProcessUtils.sanitize_commandline (kkey) == command_sanitized_basename){ - // debug(" For %s", command_sanitized_basename); - // debug(" | Found app2 %s", apps_info_list.get (key).get_commandline ()); - // process.application_name = apps_info_list.get (key).get_name (); - // process.icon = apps_info_list.get (key).get_icon (); - // } else { - //// var splitted_commandline = process.command.split (" "); - //// if (!splitted_commandline[0].contains ("/")){ - //// process.application_name = apps_info_list.get (key).get_name (); - //// process.icon = apps_info_list.get (key).get_icon (); - //// } - - //// process.application_name = process.command; - // } - // } - - - - - if (process.exists) { if (process.stat.pgrp != 0) { // regular process, add it to our cache From bac72aa2f9ece7f1d04f198e10facace6fcf89b0 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Thu, 6 Jul 2023 01:05:09 +0200 Subject: [PATCH 04/23] Add children property to Process class --- src/Managers/Process.vala | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Managers/Process.vala b/src/Managers/Process.vala index b75a9573..1706c370 100644 --- a/src/Managers/Process.vala +++ b/src/Managers/Process.vala @@ -44,6 +44,8 @@ public class Monitor.Process : GLib.Object { public Gee.HashSet open_files_paths; + public Gee.HashSet children = new Gee.HashSet (); + /** * CPU usage of this process from the last time that it was updated, measured in percent * @@ -92,6 +94,7 @@ public class Monitor.Process : GLib.Object { } exists = parse_stat () && read_cmdline (); + get_children_pids (); get_usage (0, 1); } @@ -110,7 +113,6 @@ public class Monitor.Process : GLib.Object { } // Kills the process - // Returns if kill was successful public bool kill () { // Sends a kill signal that cannot be ignored if (Posix.kill (stat.pid, Posix.Signal.KILL) == 0) { @@ -120,7 +122,6 @@ public class Monitor.Process : GLib.Object { } // Ends the process - // Returns if end was successful public bool end () { // Sends a terminate signal if (Posix.kill (stat.pid, Posix.Signal.TERM) == 0) { @@ -129,6 +130,21 @@ public class Monitor.Process : GLib.Object { return false; } + private bool get_children_pids () { + string ? children_content = ProcessUtils.read_file ("/proc/%d/task/%d/children".printf (stat.pid, stat.pid)); + if (children_content == "") { + return false; + } + + var splitted_children_pids = children_content.split (" "); + foreach (var child in splitted_children_pids) { + this.children.add (int.parse (child)); + } + + debug (children_content); + return true; + } + private bool parse_io () { var io_file = File.new_for_path ("/proc/%d/io".printf (stat.pid)); From 499ee15164f7020862ce130c85bac5457979b26c Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:41:18 +0200 Subject: [PATCH 05/23] Setting same name and icon for all children processes of a Flatpak app --- debian/control | 1 + src/Managers/Process.vala | 4 +--- src/Managers/ProcessManager.vala | 20 ++++++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/debian/control b/debian/control index 2de03ec4..ab9b29f2 100644 --- a/debian/control +++ b/debian/control @@ -18,6 +18,7 @@ Build-Depends: meson, libxnvctrl-dev, libcurl4-gnutls-dev, libjson-glib-dev, + libflatpak-dev, sassc Standards-Version: 4.1.1 diff --git a/src/Managers/Process.vala b/src/Managers/Process.vala index 1706c370..ff55c5f1 100644 --- a/src/Managers/Process.vala +++ b/src/Managers/Process.vala @@ -132,7 +132,7 @@ public class Monitor.Process : GLib.Object { private bool get_children_pids () { string ? children_content = ProcessUtils.read_file ("/proc/%d/task/%d/children".printf (stat.pid, stat.pid)); - if (children_content == "") { + if (children_content == "" || children_content == null) { return false; } @@ -140,8 +140,6 @@ public class Monitor.Process : GLib.Object { foreach (var child in splitted_children_pids) { this.children.add (int.parse (child)); } - - debug (children_content); return true; } diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index a3ef1501..324233c8 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -218,6 +218,18 @@ namespace Monitor { } + private void set_fp_name (Process process, GLib.Icon icon, string name) { + process.application_name = name; + process.icon = icon; + if (process.children.size > 0) { + foreach (int pid in process.children) { + Process _process = this.get_process (pid); + if (process == null) return; + set_fp_name (_process, icon, name); + } + } + } + private bool match_process_app (Process process) { var command_sanitized = ProcessUtils.sanitize_commandline (process.command); var command_sanitized_basename = Path.get_basename (command_sanitized); @@ -225,16 +237,16 @@ namespace Monitor { process.application_name = command_sanitized_basename; foreach (var flatpak_app in flatpak_apps) { - - if (flatpak_app.get_pid () == process.stat.pid) { + if (flatpak_app.get_pid () == process.stat.pid || flatpak_app.get_child_pid () == process.stat.pid) { debug ("###### ##Found Flatpak app: %s ", flatpak_app.get_app ()); // @TODO need to find a appinfo for this app // @TODO probably need to change the way in which appinfos are stored foreach (var key in apps_info_list.keys) { if (apps_info_list.get (key).get_id ().replace (".desktop", "") == flatpak_app.get_app ()) { debug ("%s %s", apps_info_list.get (key).get_id (), flatpak_app.get_app ()); - process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); - process.icon = apps_info_list.get (key).get_icon (); + // process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); + // process.icon = apps_info_list.get (key).get_icon (); + set_fp_name (process, apps_info_list.get (key).get_icon (), apps_info_list.get (key).get_name ()); } } } From 7327e0a3fbfa53e8be83d8b0e3a2e9208ee4fd81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw?= <6031763+stsdc@users.noreply.github.com> Date: Fri, 7 Jul 2023 11:05:48 +0200 Subject: [PATCH 06/23] Add libflatpak-dev to CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8b275e1..56c5845e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: apt update apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev apt install -y libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev - apt install -y libxnvctrl0 libxnvctrl-dev libcurl4-gnutls-dev + apt install -y libxnvctrl0 libxnvctrl-dev libcurl4-gnutls-dev libflatpak-dev apt install -y meson valac sassc git - name: Build env: From 70be106197fe85c442e50ba6b9d36149e501b1c9 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 9 Jul 2023 18:40:43 +0200 Subject: [PATCH 07/23] Fix some null assert errors in ProcessManager --- src/Managers/ProcessManager.vala | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 324233c8..244c9093 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -43,7 +43,7 @@ namespace Monitor { foreach (AppInfo app_info in _apps_info) { string commandline = (app_info.get_commandline ()); - // debug ("%s * ", app_info.get_commandline ()); + // debug ("%s * ", app_info.get_commandline ()); @@ -66,11 +66,11 @@ namespace Monitor { var running_flatpaks = Flatpak.Instance.get_all (); running_flatpaks.foreach ((fp) => { - debug ("----------<><> %s bwrap: %d app: %d", fp.get_app (), fp.get_pid(), fp.get_child_pid ()); - // debug ("%s ", fp.get_info().to_data()); + debug ("----------<><> %s bwrap: %d app: %d", fp.get_app (), fp.get_pid (), fp.get_child_pid ()); + // debug ("%s ", fp.get_info().to_data()); }); - // debug ("----------<><> %s", running_flatpaks[0]); + // debug ("----------<><> %s", running_flatpaks[0]); } @@ -218,14 +218,13 @@ namespace Monitor { } - private void set_fp_name (Process process, GLib.Icon icon, string name) { + private void set_flatpak_name_icon (Process process, GLib.Icon icon, string name) { process.application_name = name; process.icon = icon; - if (process.children.size > 0) { - foreach (int pid in process.children) { - Process _process = this.get_process (pid); - if (process == null) return; - set_fp_name (_process, icon, name); + foreach (int pid in process.children) { + var _process = this.get_process (pid); + if (_process != null) { + set_flatpak_name_icon (_process, icon, name); } } } @@ -244,9 +243,9 @@ namespace Monitor { foreach (var key in apps_info_list.keys) { if (apps_info_list.get (key).get_id ().replace (".desktop", "") == flatpak_app.get_app ()) { debug ("%s %s", apps_info_list.get (key).get_id (), flatpak_app.get_app ()); - // process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); - // process.icon = apps_info_list.get (key).get_icon (); - set_fp_name (process, apps_info_list.get (key).get_icon (), apps_info_list.get (key).get_name ()); + // process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); + // process.icon = apps_info_list.get (key).get_icon (); + set_flatpak_name_icon (process, apps_info_list.get (key).get_icon (), apps_info_list.get (key).get_name ()); } } } @@ -298,7 +297,7 @@ namespace Monitor { debug ("app name is " + process.application_name); } - // process.application_name = process.command; + // process.application_name = process.command; return true; } @@ -346,7 +345,7 @@ namespace Monitor { private void remove_process (int pid) { if (process_list.has_key (pid)) { process_list.unset (pid); - // flatpak_apps.remove (pid); + // flatpak_apps.remove (pid); foreach (var fp in flatpak_apps) { if (fp.get_pid () == pid) { flatpak_apps.remove (fp); From 61b5cb1cbbd446dde36d9a4a3644c9cbbcd91035 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 9 Jul 2023 18:54:34 +0200 Subject: [PATCH 08/23] cleanup --- src/Managers/ProcessManager.vala | 60 ++------------------------------ 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 244c9093..e2ee9ae9 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -43,10 +43,6 @@ namespace Monitor { foreach (AppInfo app_info in _apps_info) { string commandline = (app_info.get_commandline ()); - // debug ("%s * ", app_info.get_commandline ()); - - - // GLib.DesktopAppInfo? dai = info as GLib.DesktopAppInfo; // if (dai != null) { @@ -54,61 +50,13 @@ namespace Monitor { // if (id != null) // appid_map.insert (id, info); // } - - if (commandline == null) continue; - // sanitize_cmd (ref cmd); apps_info_list.set (commandline, app_info); } - - var running_flatpaks = Flatpak.Instance.get_all (); - - running_flatpaks.foreach ((fp) => { - debug ("----------<><> %s bwrap: %d app: %d", fp.get_app (), fp.get_pid (), fp.get_child_pid ()); - // debug ("%s ", fp.get_info().to_data()); - }); - - // debug ("----------<><> %s", running_flatpaks[0]); - - } - // private static void sanitize_cmd(ref string? commandline) { - // if (commandline == null) - // return; - - //// flatpak: parse the command line of the containerized program - // if (commandline.contains("flatpak run")) { - // var index = commandline.index_of ("--command=") + 10; - // commandline = commandline.substring (index); - // } - - //// TODO: unify this with the logic in get_full_process_cmd - //// commandline = Process.first_component (commandline); - //// commandline = Path.get_basename (commandline); - //// commandline = Process.sanitize_name (commandline); - - //// Workaround for google-chrome - // if (commandline.contains ("google-chrome-stable")) - // commandline = "chrome"; - // } - - // public static AppInfo? app_info_for_process (Process p) { - // AppInfo? info = null; - - // if (p.command != null) - // info = apps_info[p.command]; - - // if (info == null && p.app_id != null) - // info = appid_map[p.app_id]; - - // return info; - // } - - - /** * Gets a process by its pid, making sure that it's updated. @@ -218,6 +166,7 @@ namespace Monitor { } + /** Sets name and icon for a process that is a Flatpak app and its children. */ private void set_flatpak_name_icon (Process process, GLib.Icon icon, string name) { process.application_name = name; process.icon = icon; @@ -237,14 +186,9 @@ namespace Monitor { foreach (var flatpak_app in flatpak_apps) { if (flatpak_app.get_pid () == process.stat.pid || flatpak_app.get_child_pid () == process.stat.pid) { - debug ("###### ##Found Flatpak app: %s ", flatpak_app.get_app ()); - // @TODO need to find a appinfo for this app - // @TODO probably need to change the way in which appinfos are stored + debug ("Found Flatpak app: %s ", flatpak_app.get_app ()); foreach (var key in apps_info_list.keys) { if (apps_info_list.get (key).get_id ().replace (".desktop", "") == flatpak_app.get_app ()) { - debug ("%s %s", apps_info_list.get (key).get_id (), flatpak_app.get_app ()); - // process.application_name = "Bubblewrap: " + apps_info_list.get (key).get_name (); - // process.icon = apps_info_list.get (key).get_icon (); set_flatpak_name_icon (process, apps_info_list.get (key).get_icon (), apps_info_list.get (key).get_name ()); } } From a775b657cfd9a85427b2395f0c4f380251ab916a Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 9 Jul 2023 23:20:47 +0200 Subject: [PATCH 09/23] Search processes by command --- src/Models/TreeViewModel.vala | 3 +++ src/Widgets/Headerbar/Search.vala | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Models/TreeViewModel.vala b/src/Models/TreeViewModel.vala index 330a3a1c..4394f823 100644 --- a/src/Models/TreeViewModel.vala +++ b/src/Models/TreeViewModel.vala @@ -4,6 +4,7 @@ public enum Monitor.Column { CPU, MEMORY, PID, + CMD } public class Monitor.TreeViewModel : Gtk.TreeStore { @@ -20,6 +21,7 @@ public class Monitor.TreeViewModel : Gtk.TreeStore { typeof (double), typeof (int64), typeof (int), + typeof (string), }); process_manager = ProcessManager.get_default (); @@ -53,6 +55,7 @@ public class Monitor.TreeViewModel : Gtk.TreeStore { Column.NAME, process.application_name, Column.ICON, process.icon.to_string (), Column.PID, process.stat.pid, + Column.CMD, process.command, -1); if (process_rows.size < 1) { added_first_row (); diff --git a/src/Widgets/Headerbar/Search.vala b/src/Widgets/Headerbar/Search.vala index 65656f08..922f00f6 100644 --- a/src/Widgets/Headerbar/Search.vala +++ b/src/Widgets/Headerbar/Search.vala @@ -43,6 +43,7 @@ public class Monitor.Search : Gtk.SearchEntry { private bool filter_func (Gtk.TreeModel model, Gtk.TreeIter iter) { string name_haystack; int pid_haystack; + string cmd_haystack; bool found = false; var needle = this.text; @@ -55,12 +56,14 @@ public class Monitor.Search : Gtk.SearchEntry { model.get (iter, Column.NAME, out name_haystack, -1); model.get (iter, Column.PID, out pid_haystack, -1); + model.get (iter, Column.CMD, out cmd_haystack, -1); // sometimes name_haystack is null if (name_haystack != null) { bool name_found = name_haystack.casefold ().contains (needle.casefold ()) || false; bool pid_found = pid_haystack.to_string ().casefold ().contains (needle.casefold ()) || false; - found = name_found || pid_found; + bool cmd_found = cmd_haystack.casefold ().contains (needle.casefold ()) || false; + found = name_found || pid_found || cmd_found; } From 8786e76a45cce6cf90099e140700dea7932412e5 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:05:35 +0200 Subject: [PATCH 10/23] Fix assigning name and icon to some processes that are connected to Flatpak app --- src/Managers/ProcessManager.vala | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index e2ee9ae9..a5cf2b70 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -16,9 +16,6 @@ namespace Monitor { private Gee.TreeMap process_list; private Gee.HashSet kernel_process_blacklist; private Gee.HashMap apps_info_list; - private Gee.HashSet flatpak_apps = new Gee.HashSet (); - - public signal void process_added (Process process); public signal void process_removed (int pid); @@ -31,10 +28,6 @@ namespace Monitor { apps_info_list = new Gee.HashMap (); populate_apps_info (); - Flatpak.Instance.get_all ().foreach ((fp) => { - flatpak_apps.add (fp); - }); - update_processes.begin (); } @@ -157,9 +150,7 @@ namespace Monitor { cpu_last_totals = cpu_data.xcpu_total; - Flatpak.Instance.get_all ().foreach ((fp) => { - flatpak_apps.add (fp); - }); + /* emit the updated signal so that subscribers can update */ updated (); @@ -184,7 +175,7 @@ namespace Monitor { process.application_name = command_sanitized_basename; - foreach (var flatpak_app in flatpak_apps) { + foreach (var flatpak_app in Flatpak.Instance.get_all ()) { if (flatpak_app.get_pid () == process.stat.pid || flatpak_app.get_child_pid () == process.stat.pid) { debug ("Found Flatpak app: %s ", flatpak_app.get_app ()); foreach (var key in apps_info_list.keys) { @@ -289,13 +280,6 @@ namespace Monitor { private void remove_process (int pid) { if (process_list.has_key (pid)) { process_list.unset (pid); - // flatpak_apps.remove (pid); - foreach (var fp in flatpak_apps) { - if (fp.get_pid () == pid) { - flatpak_apps.remove (fp); - break; - } - } process_removed (pid); } else if (kernel_process_blacklist.contains (pid)) { kernel_process_blacklist.remove (pid); From 566c40bb96e37f47d6b74c0383e466d36001ee6b Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sat, 15 Jul 2023 00:24:55 +0200 Subject: [PATCH 11/23] reafactor --- src/Views/SystemView/SystemCPUView.vala | 8 -------- src/Widgets/Statusbar/Statusbar.vala | 10 +++------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index f48ef60c..efbd2435 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -4,7 +4,6 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { private Chart cpu_temperature_chart; private CPU cpu; - private LabelVertical cpu_percentage_label; private LabelRoundy cpu_frequency_label; private LabelRoundy cpu_temperature_label; @@ -15,10 +14,6 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { construct { core_label_list = new Gee.ArrayList (); - cpu_percentage_label = new LabelVertical (_("Utilization")); - cpu_percentage_label.has_tooltip = true; - cpu_percentage_label.tooltip_text = (_("Show detailed info")); - cpu_frequency_label = new LabelRoundy (_("Frequency")); cpu_frequency_label.margin = 6; cpu_frequency_label.margin_top = 2; @@ -32,9 +27,6 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { cpu_frequency_chart.height_request = -1; cpu_frequency_chart.config.y_axis.fixed_max = 5.0; - - - var grid_frequency_info = new Gtk.Grid (); grid_frequency_info.attach (cpu_frequency_label, 0, 0, 1, 1); grid_frequency_info.attach (cpu_frequency_chart, 0, 0, 1, 1); diff --git a/src/Widgets/Statusbar/Statusbar.vala b/src/Widgets/Statusbar/Statusbar.vala index 9b167b71..b93fdcc8 100644 --- a/src/Widgets/Statusbar/Statusbar.vala +++ b/src/Widgets/Statusbar/Statusbar.vala @@ -33,25 +33,21 @@ public class Monitor.Statusbar : Gtk.ActionBar { pack_start (swap_icon); pack_start (swap_usage_label); - var peace_label = new Gtk.Label ("🕊️"); - peace_label.tooltip_text = (_("Peace")); + var support_ua_label = new Gtk.LinkButton.with_label ("https://u24.gov.ua/", _("🇺🇦")); var github_label = new Gtk.LinkButton.with_label ("https://github.com/stsdc/monitor", _("Check on Github")); - var donate_label = new Gtk.LinkButton.with_label ("https://ko-fi.com/stsdc", _("Donate 💸")); - var version_label = new Gtk.Label ("%s".printf (VCS_TAG)) { selectable = true }; version_label.get_style_context ().add_class ("dim-label"); - pack_end (donate_label); - pack_end (build_separator_middot ()); + // pack_end (build_separator_middot ()); pack_end (github_label); pack_end (build_separator_middot ()); pack_end (version_label); pack_end (build_separator_middot ()); - pack_end (peace_label); + pack_end (support_ua_label); } From b5857d134f57b053a4c60f8e103b4385f0d4e0bf Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sat, 15 Jul 2023 00:44:42 +0200 Subject: [PATCH 12/23] Fix for icons appear slightly smaller in detailed process view --- data/icons/icons.indicator.gresource.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/icons/icons.indicator.gresource.xml b/data/icons/icons.indicator.gresource.xml index 003597b8..2c420d17 100644 --- a/data/icons/icons.indicator.gresource.xml +++ b/data/icons/icons.indicator.gresource.xml @@ -9,7 +9,9 @@ temperature-sensor-symbolic.svg extra/16/bash.svg extra/48/bash.svg + extra/64/bash.svg extra/16/docker.svg extra/48/docker.svg + extra/64/docker.svg \ No newline at end of file From 83c260d4750fe2cc2054ccb9fa876f09a624b053 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sat, 15 Jul 2023 01:11:40 +0200 Subject: [PATCH 13/23] show fullprocess command if contains ":"; refactor --- src/Managers/ProcessManager.vala | 17 ++++++++++------- src/Managers/ProcessUtils.vala | 8 -------- src/Widgets/Statusbar/Statusbar.vala | 18 ++++++++++-------- subprojects/live-chart | 2 +- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index a5cf2b70..162c455b 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -50,7 +50,6 @@ namespace Monitor { } } - /** * Gets a process by its pid, making sure that it's updated. */ @@ -149,9 +148,6 @@ namespace Monitor { cpu_last_useds = useds; cpu_last_totals = cpu_data.xcpu_total; - - - /* emit the updated signal so that subscribers can update */ updated (); @@ -201,6 +197,7 @@ namespace Monitor { return true; } } + // Steam case // Must match a proper executable and not game executable e.g. steam steam://rungameid/210770 if ((Path.get_basename (key.split (" ")[0]) == command_sanitized_basename) && !key.split (" ")[1].contains ("steam")) { @@ -209,7 +206,7 @@ namespace Monitor { return true; } - // workaround for some flatpak apps + //// workaround for some flatpak apps if (process.command.contains (apps_info_list.get (key).get_id ().replace (".desktop", ""))) { process.application_name = apps_info_list.get (key).get_name (); process.icon = apps_info_list.get (key).get_icon (); @@ -219,15 +216,21 @@ namespace Monitor { process.application_name = apps_info_list.get (key).get_name (); process.icon = apps_info_list.get (key).get_icon (); return true; + + // some processes have semicolon in command + // do not sanitizeng to improve readability + } else if (process.command.split (" ")[0].contains (":")) { + process.application_name = process.command; + return true; } } if (ProcessUtils.is_shell (command_sanitized_basename)) { - process.icon = ProcessUtils.get_bash_icon (); + process.icon = new ThemedIcon ("bash"); debug ("app name is " + process.application_name); } if (command_sanitized_basename == "docker" || command_sanitized_basename == "dockerd" || command_sanitized_basename == "docker-proxy") { - process.icon = ProcessUtils.get_docker_icon (); + process.icon = new ThemedIcon ("docker"); process.application_name = command_sanitized_basename; debug ("app name is " + process.application_name); } diff --git a/src/Managers/ProcessUtils.vala b/src/Managers/ProcessUtils.vala index 6389c6f1..31807093 100644 --- a/src/Managers/ProcessUtils.vala +++ b/src/Managers/ProcessUtils.vala @@ -62,12 +62,4 @@ public class Monitor.ProcessUtils { return null; } } - - public static Icon ? get_bash_icon () { - return new ThemedIcon ("bash"); - } - - public static Icon ? get_docker_icon () { - return new ThemedIcon ("docker"); - } } diff --git a/src/Widgets/Statusbar/Statusbar.vala b/src/Widgets/Statusbar/Statusbar.vala index b93fdcc8..50ff97d8 100644 --- a/src/Widgets/Statusbar/Statusbar.vala +++ b/src/Widgets/Statusbar/Statusbar.vala @@ -4,14 +4,17 @@ public class Monitor.Statusbar : Gtk.ActionBar { Gtk.Label swap_usage_label; construct { - var cpu_icon = new Gtk.Image.from_icon_name ("cpu-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - cpu_icon.tooltip_text = _("CPU"); + var cpu_icon = new Gtk.Image.from_icon_name ("cpu-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + tooltip_text = _("CPU") + }; - var ram_icon = new Gtk.Image.from_icon_name ("ram-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - ram_icon.tooltip_text = _("Memory"); + var ram_icon = new Gtk.Image.from_icon_name ("ram-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + tooltip_text = _("Memory") + }; - var swap_icon = new Gtk.Image.from_icon_name ("swap-symbolic", Gtk.IconSize.SMALL_TOOLBAR); - swap_icon.tooltip_text = _("Swap"); + var swap_icon = new Gtk.Image.from_icon_name ("swap-symbolic", Gtk.IconSize.SMALL_TOOLBAR) { + tooltip_text = _("Swap") + }; cpu_usage_label = new Gtk.Label (_("Calculating…")); cpu_usage_label.set_width_chars (4); @@ -34,7 +37,6 @@ public class Monitor.Statusbar : Gtk.ActionBar { pack_start (swap_usage_label); var support_ua_label = new Gtk.LinkButton.with_label ("https://u24.gov.ua/", _("🇺🇦")); - var github_label = new Gtk.LinkButton.with_label ("https://github.com/stsdc/monitor", _("Check on Github")); var version_label = new Gtk.Label ("%s".printf (VCS_TAG)) { @@ -42,7 +44,7 @@ public class Monitor.Statusbar : Gtk.ActionBar { }; version_label.get_style_context ().add_class ("dim-label"); - // pack_end (build_separator_middot ()); + // pack_end (build_separator_middot ()); pack_end (github_label); pack_end (build_separator_middot ()); pack_end (version_label); diff --git a/subprojects/live-chart b/subprojects/live-chart index 1c090e18..5f8ddce7 160000 --- a/subprojects/live-chart +++ b/subprojects/live-chart @@ -1 +1 @@ -Subproject commit 1c090e18fa4ae9f3ccfe0f38d619ebeccd7d6361 +Subproject commit 5f8ddce715f6a9130955bc5f08437050265a317c From 24734dece4d9df936271f5a15481db558e704add Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 16 Jul 2023 15:46:18 +0200 Subject: [PATCH 14/23] Improve wine process display --- src/Managers/ProcessManager.vala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 162c455b..2c41f5f6 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -206,7 +206,7 @@ namespace Monitor { return true; } - //// workaround for some flatpak apps + // workaround for some flatpak apps if (process.command.contains (apps_info_list.get (key).get_id ().replace (".desktop", ""))) { process.application_name = apps_info_list.get (key).get_name (); process.icon = apps_info_list.get (key).get_icon (); @@ -217,9 +217,16 @@ namespace Monitor { process.icon = apps_info_list.get (key).get_icon (); return true; + + } else if (process.command.split (" ")[0].contains (".exe")) { + var splitted = process.command.split (" ")[0].split ("\\"); + process.application_name = splitted[splitted.length - 1].chomp(); + process.icon = new ThemedIcon ("application-x-ms-dos-executable"); + return true; + } // some processes have semicolon in command - // do not sanitizeng to improve readability - } else if (process.command.split (" ")[0].contains (":")) { + // do not sanitizing to improve readability + else if (process.command.split (" ")[0].contains (":")) { process.application_name = process.command; return true; } From e4180d003c8af7b2dd9a280e90a5f41ef5accd36 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:13:20 +0200 Subject: [PATCH 15/23] Display GPU temperature in the Indicator. Closes #326 --- data/com.github.stsdc.monitor.gschema.xml | 5 ++ data/icons/icons.indicator.gresource.xml | 1 + data/icons/temperature-gpu-symbolic.svg | 49 +++++++++++++++ src/Indicator/Indicator.vala | 3 + src/Indicator/Services/DBusClient.vala | 1 + src/Indicator/Widgets/DisplayWidget.vala | 2 + src/Managers/ContainerManager.vala | 59 ++++++++----------- src/Resources/Resources.vala | 3 +- src/Resources/ResourcesSerialized.vala | 1 + src/Services/DBusServer.vala | 1 + .../ContainerInfoHeader.vala | 38 ------------ .../PreferencesIndicatorPage.vala | 27 +++++++-- src/Widgets/Statusbar/Statusbar.vala | 2 +- 13 files changed, 111 insertions(+), 81 deletions(-) create mode 100644 data/icons/temperature-gpu-symbolic.svg diff --git a/data/com.github.stsdc.monitor.gschema.xml b/data/com.github.stsdc.monitor.gschema.xml index 34b7f91b..a242f8ff 100644 --- a/data/com.github.stsdc.monitor.gschema.xml +++ b/data/com.github.stsdc.monitor.gschema.xml @@ -70,6 +70,11 @@ To show GPU used percentage in Monitor Indicator or not To show GPU used percentage in Monitor Indicator or not + + false + To show GPU temperature in Monitor Indicator or not + To show GPU temperature in Monitor Indicator or not + true To enable smooth lines in charts diff --git a/data/icons/icons.indicator.gresource.xml b/data/icons/icons.indicator.gresource.xml index 2c420d17..fc41b25c 100644 --- a/data/icons/icons.indicator.gresource.xml +++ b/data/icons/icons.indicator.gresource.xml @@ -7,6 +7,7 @@ swap-symbolic.svg file-deleted-symbolic.svg temperature-sensor-symbolic.svg + temperature-gpu-symbolic.svg extra/16/bash.svg extra/48/bash.svg extra/64/bash.svg diff --git a/data/icons/temperature-gpu-symbolic.svg b/data/icons/temperature-gpu-symbolic.svg new file mode 100644 index 00000000..138823fb --- /dev/null +++ b/data/icons/temperature-gpu-symbolic.svg @@ -0,0 +1,49 @@ + +image/svg+xml diff --git a/src/Indicator/Indicator.vala b/src/Indicator/Indicator.vala index 33fe5d50..0a95547e 100644 --- a/src/Indicator/Indicator.vala +++ b/src/Indicator/Indicator.vala @@ -29,6 +29,7 @@ public class Monitor.Indicator : Wingpanel.Indicator { display_widget.network_up_widget.visible = settings.get_boolean ("indicator-network-upload-state"); display_widget.network_down_widget.visible = settings.get_boolean ("indicator-network-download-state"); display_widget.gpu_widget.visible = settings.get_boolean ("indicator-gpu-state"); + display_widget.gpu_temperature_widget.visible = settings.get_boolean ("indicator-gpu-temperature-state"); }); @@ -39,6 +40,7 @@ public class Monitor.Indicator : Wingpanel.Indicator { dbusclient.interface.indicator_network_up_state.connect ((state) => display_widget.network_up_widget.visible = state); dbusclient.interface.indicator_network_down_state.connect ((state) => display_widget.network_down_widget.visible = state); dbusclient.interface.indicator_gpu_state.connect ((state) => display_widget.gpu_widget.visible = state); + dbusclient.interface.indicator_gpu_temperature_state.connect ((state) => display_widget.gpu_temperature_widget.visible = state); dbusclient.interface.update.connect ((sysres) => { display_widget.cpu_widget.state_percentage = sysres.cpu_percentage; @@ -47,6 +49,7 @@ public class Monitor.Indicator : Wingpanel.Indicator { display_widget.network_up_widget.state_bandwidth = sysres.network_up; display_widget.network_down_widget.state_bandwidth = sysres.network_down; display_widget.gpu_widget.state_percentage = sysres.gpu_percentage; + display_widget.gpu_temperature_widget.state_temperature = (int) Math.round (sysres.gpu_temperature); }); popover_widget.quit_monitor.connect (() => { diff --git a/src/Indicator/Services/DBusClient.vala b/src/Indicator/Services/DBusClient.vala index 8e0894be..b15bfde9 100644 --- a/src/Indicator/Services/DBusClient.vala +++ b/src/Indicator/Services/DBusClient.vala @@ -10,6 +10,7 @@ public interface Monitor.DBusClientInterface : Object { public signal void indicator_network_up_state (bool state); public signal void indicator_network_down_state (bool state); public signal void indicator_gpu_state (bool state); + public signal void indicator_gpu_temperature_state (bool state); } diff --git a/src/Indicator/Widgets/DisplayWidget.vala b/src/Indicator/Widgets/DisplayWidget.vala index 5c994264..3dc40ed2 100644 --- a/src/Indicator/Widgets/DisplayWidget.vala +++ b/src/Indicator/Widgets/DisplayWidget.vala @@ -7,6 +7,7 @@ public class Monitor.Widgets.DisplayWidget : Gtk.Grid { public IndicatorWidget network_down_widget = new IndicatorWidget ("go-down-symbolic"); public IndicatorWidget gpu_widget = new IndicatorWidget ("gpu-symbolic"); + public IndicatorWidget gpu_temperature_widget = new IndicatorWidget ("temperature-gpu-symbolic"); construct { valign = Gtk.Align.CENTER; @@ -14,6 +15,7 @@ public class Monitor.Widgets.DisplayWidget : Gtk.Grid { add (cpu_widget); add (memory_widget); add (gpu_widget); + add (gpu_temperature_widget); add (temperature_widget); add (network_up_widget); add (network_down_widget); diff --git a/src/Managers/ContainerManager.vala b/src/Managers/ContainerManager.vala index 118277af..9d04fae1 100644 --- a/src/Managers/ContainerManager.vala +++ b/src/Managers/ContainerManager.vala @@ -6,30 +6,30 @@ namespace Monitor { ERROR_NO_ENTRY, } - struct Container { - public string id; - public string name; - public string image; - public string state; - public string ? label_project; - public string ? label_service; - public string ? label_config; - public string ? label_workdir; - } - - struct ContainerInspectInfo { - public string name; - public string image; - public string status; - public string[] ? binds; - public string[] ? envs; - public string[] ? ports; - } - - struct DockerVersionInfo { - public string version; - public string api_version; - } + // struct Container { + // public string id; + // public string name; + // public string image; + // public string state; + // public string ? label_project; + // public string ? label_service; + // public string ? label_config; + // public string ? label_workdir; + // } + + // struct ContainerInspectInfo { + // public string name; + // public string image; + // public string status; + // public string[] ? binds; + // public string[] ? envs; + // public string[] ? ports; + // } + + // struct DockerVersionInfo { + // public string version; + // public string api_version; + // } public class ContainerManager : Object { private static GLib.Once instance; @@ -141,7 +141,6 @@ namespace Monitor { throw new ApiClientError.ERROR ("Server error"); } - // var json = ""; string ? line = null; @@ -149,7 +148,6 @@ namespace Monitor { json += line; } - // var root_node = parse_json (json); var root_array = root_node.get_array (); assert_nonnull (root_array); @@ -161,15 +159,6 @@ namespace Monitor { this.add_container (container_object); - // - - - - // - - - // - } var remove_me = new Gee.HashSet (); foreach (var container in this.container_list.values) { diff --git a/src/Resources/Resources.vala b/src/Resources/Resources.vala index 20cc6a6b..1238dd0b 100644 --- a/src/Resources/Resources.vala +++ b/src/Resources/Resources.vala @@ -86,7 +86,8 @@ public class Monitor.Resources : Object { swap_total = swap.total, network_up = network.bytes_out, network_down = network.bytes_in, - gpu_percentage = gpu != null ? gpu.percentage : 0 + gpu_percentage = gpu != null ? gpu.percentage : 0, + gpu_temperature = gpu.temperature }; } } diff --git a/src/Resources/ResourcesSerialized.vala b/src/Resources/ResourcesSerialized.vala index 33a6456b..b389793c 100644 --- a/src/Resources/ResourcesSerialized.vala +++ b/src/Resources/ResourcesSerialized.vala @@ -11,4 +11,5 @@ public struct ResourcesSerialized { public int network_up; public int network_down; public int gpu_percentage; + public double gpu_temperature; } diff --git a/src/Services/DBusServer.vala b/src/Services/DBusServer.vala index 705e4748..f19f0840 100644 --- a/src/Services/DBusServer.vala +++ b/src/Services/DBusServer.vala @@ -17,6 +17,7 @@ public class Monitor.DBusServer : Object { public signal void indicator_network_up_state (bool state); public signal void indicator_network_down_state (bool state); public signal void indicator_gpu_state (bool state); + public signal void indicator_gpu_temperature_state (bool state); public signal void quit (); public signal void show (); diff --git a/src/Views/ContainerView/ContainerInfoView/ContainerInfoHeader.vala b/src/Views/ContainerView/ContainerInfoView/ContainerInfoHeader.vala index 6d378c9f..bff68aa9 100644 --- a/src/Views/ContainerView/ContainerInfoView/ContainerInfoHeader.vala +++ b/src/Views/ContainerView/ContainerInfoView/ContainerInfoHeader.vala @@ -99,42 +99,4 @@ public class Monitor.ContainerInfoHeader : Gtk.Grid { // num_threads.set_text (process.stat.num_threads.to_string ()); // set_icon (process); } - - private void set_icon (Process process) { - // this construction should be somewhere else - var icon_name = process.icon.to_string (); - - if (!regex.match (icon_name)) { - icon.set_from_icon_name (icon_name, Gtk.IconSize.DIALOG); - } else { - try { - var pixbuf = new Gdk.Pixbuf.from_file_at_size (icon_name, 64, -1); - icon.set_from_pixbuf (pixbuf); - } catch (Error e) { - warning (e.message); - } - } - } - - private string set_state_tooltip () { - switch (state.label) { - case "D": - return _("The app is waiting in an uninterruptible disk sleep"); - case "I": - return _("Idle kernel thread"); - case "R": - return _("The process is running or runnable (on run queue)"); - case "S": - return _("The process is in an interruptible sleep; waiting for an event to complete"); - case "T": - return _("The process is stopped by a job control signal"); - case "t": - return _("The process is stopped stopped by a debugger during the tracing"); - case "Z": - return _("The app is terminated but not reaped by its parent"); - default: - return ""; - } - } - } diff --git a/src/Views/PreferencesView/PreferencesIndicatorPage.vala b/src/Views/PreferencesView/PreferencesIndicatorPage.vala index a3b7cdb4..57af79ba 100644 --- a/src/Views/PreferencesView/PreferencesIndicatorPage.vala +++ b/src/Views/PreferencesView/PreferencesIndicatorPage.vala @@ -94,6 +94,18 @@ dbusserver.indicator_gpu_state (gpu_percentage_switch.state); }); + var gpu_temperature_label = new Gtk.Label (_("Display GPU temperature")); + gpu_label.halign = Gtk.Align.START; + gpu_label.xalign = 1; + + var gpu_temperature_switch = new Gtk.Switch (); + gpu_temperature_switch.halign = Gtk.Align.END; + gpu_temperature_switch.state = MonitorApp.settings.get_boolean ("indicator-gpu-temperature-state"); + gpu_temperature_switch.notify["active"].connect (() => { + MonitorApp.settings.set_boolean ("indicator-gpu-temperature-state", gpu_temperature_switch.state); + dbusserver.indicator_gpu_temperature_state (gpu_temperature_switch.state); + }); + content_area.attach (cpu_label, 0, 0, 1, 1); content_area.attach (cpu_percentage_switch, 1, 0, 1, 1); @@ -103,14 +115,17 @@ content_area.attach (gpu_label, 0, 2, 1, 1); content_area.attach (gpu_percentage_switch, 1, 2, 1, 1); - content_area.attach (temperature_label, 0, 3, 1, 1); - content_area.attach (temperature_switch, 1, 3, 1, 1); + content_area.attach (gpu_temperature_label, 0, 3, 1, 1); + content_area.attach (gpu_temperature_switch, 1, 3, 1, 1); + + content_area.attach (temperature_label, 0, 4, 1, 1); + content_area.attach (temperature_switch, 1, 4, 1, 1); - content_area.attach (network_upload_label, 0, 4, 1, 1); - content_area.attach (network_upload_switch, 1, 4, 1, 1); + content_area.attach (network_upload_label, 0, 5, 1, 1); + content_area.attach (network_upload_switch, 1, 5, 1, 1); - content_area.attach (network_download_label, 0, 5, 1, 1); - content_area.attach (network_download_switch, 1, 5, 1, 1); + content_area.attach (network_download_label, 0, 6, 1, 1); + content_area.attach (network_download_switch, 1, 6, 1, 1); update_status (); diff --git a/src/Widgets/Statusbar/Statusbar.vala b/src/Widgets/Statusbar/Statusbar.vala index 50ff97d8..ed45634c 100644 --- a/src/Widgets/Statusbar/Statusbar.vala +++ b/src/Widgets/Statusbar/Statusbar.vala @@ -36,7 +36,7 @@ public class Monitor.Statusbar : Gtk.ActionBar { pack_start (swap_icon); pack_start (swap_usage_label); - var support_ua_label = new Gtk.LinkButton.with_label ("https://u24.gov.ua/", _("🇺🇦")); + var support_ua_label = new Gtk.LinkButton.with_label ("http://stand-with-ukraine.pp.ua/", _("🇺🇦")); var github_label = new Gtk.LinkButton.with_label ("https://github.com/stsdc/monitor", _("Check on Github")); var version_label = new Gtk.Label ("%s".printf (VCS_TAG)) { From 8f17ccb60f2ab0b614ffcc32deb306a01320f5ee Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:15:24 +0200 Subject: [PATCH 16/23] fix linting --- src/Managers/ProcessManager.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Managers/ProcessManager.vala b/src/Managers/ProcessManager.vala index 2c41f5f6..b2d38659 100644 --- a/src/Managers/ProcessManager.vala +++ b/src/Managers/ProcessManager.vala @@ -220,7 +220,7 @@ namespace Monitor { } else if (process.command.split (" ")[0].contains (".exe")) { var splitted = process.command.split (" ")[0].split ("\\"); - process.application_name = splitted[splitted.length - 1].chomp(); + process.application_name = splitted[splitted.length - 1].chomp (); process.icon = new ThemedIcon ("application-x-ms-dos-executable"); return true; } From 1f76c37400373002f563cc8070e8daa2f3e3a50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw?= <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:19:12 +0200 Subject: [PATCH 17/23] Update FUNDING.yml --- .github/FUNDING.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 8f027c53..8b137891 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1 @@ -ko_fi: stsdc -custom: https://www.paypal.me/stsdc \ No newline at end of file + From 209c645d0d37a542dcd0a028d32118b7fb86f39a Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:26:11 +0200 Subject: [PATCH 18/23] Make value in RoundyLabel selectable --- src/Widgets/Labels/LabelRoundy.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Widgets/Labels/LabelRoundy.vala b/src/Widgets/Labels/LabelRoundy.vala index dd585114..2687af84 100644 --- a/src/Widgets/Labels/LabelRoundy.vala +++ b/src/Widgets/Labels/LabelRoundy.vala @@ -3,7 +3,9 @@ public class Monitor.LabelRoundy : Gtk.Fixed { public Gtk.Label desc; public LabelRoundy (string description) { - val = new Gtk.Label (Utils.NO_DATA); + val = new Gtk.Label (Utils.NO_DATA) { + selectable = true + }; val.get_style_context ().add_class ("roundy-label"); desc = new Gtk.Label (description.up ()); From a9b425732d4ae661cdcf31ae3d7517b0ddf5bee0 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:42:52 +0200 Subject: [PATCH 19/23] bump version to 0.17.0 --- com.github.stsdc.monitor.spec | 2 +- debian/changelog | 9 +++++++++ meson.build | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/com.github.stsdc.monitor.spec b/com.github.stsdc.monitor.spec index 8b0cf706..4a916f94 100755 --- a/com.github.stsdc.monitor.spec +++ b/com.github.stsdc.monitor.spec @@ -2,7 +2,7 @@ %global appname com.github.stsdc.monitor Name: com.github.stsdc.monitor -Version: 0.16.1 +Version: 0.17.0 Release: %autorelease Summary: Manage processes and monitor system resources License: GPLv3 diff --git a/debian/changelog b/debian/changelog index 449c778c..b6c76782 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +com.github.stsdc.monitor (0.17.0) jammy; urgency=low + + * Add GPU temperature to the Indicator + * Fix assigning right icon and name to a process (special thanks to @ppvan and @Nahu) + * Allow to filter processes by command + * Fix for icons appear slightly smaller in detailed process view + + -- Stanisław Dac Sun, 23 Jul 2023 00:35:37 +0000 + com.github.stsdc.monitor (0.16.1-0) jammy; urgency=low * Fix segfault when user can't be retrieved for process diff --git a/meson.build b/meson.build index d9c2b993..2c47b0f3 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('com.github.stsdc.monitor', 'vala', 'c', version: '0.16.1') +project('com.github.stsdc.monitor', 'vala', 'c', version: '0.17.0') # these are Meson modules gnome = import('gnome') From 24b7352b30c1a9b657f3f210f0f318825fc716a3 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:50:58 +0200 Subject: [PATCH 20/23] add libflatpak-dev to CI --- .github/workflows/publish-launchpad.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-launchpad.yml b/.github/workflows/publish-launchpad.yml index 3309d707..9a62bf83 100644 --- a/.github/workflows/publish-launchpad.yml +++ b/.github/workflows/publish-launchpad.yml @@ -40,7 +40,7 @@ jobs: apt update apt install -y devscripts dput locales apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev libxnvctrl0 libxnvctrl-dev - apt install -y libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev appstream debhelper libudisks2-dev libcurl4-gnutls-dev + apt install -y libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev appstream debhelper libudisks2-dev libcurl4-gnutls-dev libflatpak-dev apt install -y meson valac sassc git - name: Set locale From afbe465ea4dc67185f3965ee93c8d87a7aaadb71 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Tue, 22 Aug 2023 22:53:23 +0200 Subject: [PATCH 21/23] update readme --- README.md | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d51f75a2..0ce1609c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ## Install -### elementary os 6 and 6.1 +### elementary OS 7 Horus If you have never added a PPA on your system before, you might need to run this command first: @@ -41,9 +41,12 @@ sudo add-apt-repository ppa:stsdc/monitor sudo apt install com.github.stsdc.monitor ``` -Monitor will then be available from the Applications menu. +Monitor will be available from the Applications menu. -### Fedora (36) +### ~~Fedora (36)~~ + +> [!WARNING] +> Dropped support due to lack of Pantheon dependencies on COPR. ```bash sudo dnf copr enable stsdc/monitor @@ -54,23 +57,7 @@ sudo dnf install com.github.stsdc.monitor ### Install dependencies -* meson -* appstream -* debhelper (>= 9) -* libgtk-3-dev -* libglib2.0-dev -* valac (>= 0.26) -* libgranite-dev (>= 5.2.0) -* libwnck-3-dev -* libgtop2-dev -* libwingpanel-3.0-dev -* libhandy-1-dev -* libudisks2-dev -* libxnvctrl0 -* libxnvctrl-dev -* libcurl4-gnutls-dev -* libjson-glib-dev -* sassc +Check dependencies in [the deb control file](debian/control). ### Clone, Build & Install From fd369e08c2820adc2d736943d6a0d5821a3352e6 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Tue, 22 Aug 2023 22:58:37 +0200 Subject: [PATCH 22/23] update readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 0ce1609c..32d3ab76 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,6 @@

Manage processes and monitor system resources

- - - - Buy Me A Coffee Release From 002146e81985d307add585fb63f80aaecd344b4c Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:48:35 +0200 Subject: [PATCH 23/23] use with_default for json objects --- src/Managers/Container.vala | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Managers/Container.vala b/src/Managers/Container.vala index 980c1c3f..2c30e693 100644 --- a/src/Managers/Container.vala +++ b/src/Managers/Container.vala @@ -158,11 +158,8 @@ namespace Monitor { // Newer version of json library has default values option if (json_memory_stats.has_member ("stats")) { var json_memory_stats_stats = json_memory_stats.get_object_member ("stats"); - this.mem_used = json_memory_stats.get_int_member ("usage") - json_memory_stats_stats.get_int_member ("inactive_file"); - this.mem_available = json_memory_stats.get_int_member ("limit"); - } else { - this.mem_used = 0; - this.mem_available = 0; + this.mem_used = json_memory_stats.get_int_member_with_default ("usage", 0) - json_memory_stats_stats.get_int_member ("inactive_file"); + this.mem_available = json_memory_stats.get_int_member_with_default ("limit", 0); } var json_cpu_stats = root_object.get_object_member ("cpu_stats"); @@ -177,14 +174,10 @@ namespace Monitor { if (json_cpu_stats.has_member ("system_cpu_usage")) { - this.system_cpu_usage = json_cpu_stats.get_int_member ("system_cpu_usage"); - this.pre_system_cpu_usage = json_precpu_stats.get_int_member ("system_cpu_usage"); - - this.number_cpus = json_cpu_stats.get_int_member ("online_cpus"); - } else { - this.system_cpu_usage = 0; - this.pre_system_cpu_usage = 0; - this.number_cpus = 0; + this.system_cpu_usage = json_cpu_stats.get_int_member_with_default ("system_cpu_usage", 0); + this.pre_system_cpu_usage = json_precpu_stats.get_int_member_with_default ("system_cpu_usage", 0); + + this.number_cpus = json_cpu_stats.get_int_member_with_default ("online_cpus", 0); } // debug("%lld, %lld", total_usage, pretotal_usage);