Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Feb 28, 2024
1 parent 10bb4a8 commit 1e0645d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/Resources/GPU/GPUAmd.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Monitor.GPUAmd : IGPU, Object {
public SessionManager? session_manager { get; protected set; }
public SessionManager ? session_manager { get; protected set; }

public Gee.HashMap<string, HwmonTemperature> hwmon_temperatures { get; set; }

Expand All @@ -16,7 +16,7 @@ public class Monitor.GPUAmd : IGPU, Object {
public double temperature { get; protected set; }

construct {
// session_manager = get_sessman ();
// session_manager = get_sessman ();
}

private void update_temperature () {
Expand Down Expand Up @@ -46,4 +46,5 @@ public class Monitor.GPUAmd : IGPU, Object {
update_memory_percentage ();
update_percentage ();
}

}
40 changes: 25 additions & 15 deletions src/Resources/GPU/GPUNvidia.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Monitor.GPUNvidia : IGPU, Object {
public SessionManager? session_manager { get; protected set; }
public SessionManager ? session_manager { get; protected set; }

public Gee.HashMap<string, HwmonTemperature> hwmon_temperatures { get; set; }

Expand All @@ -23,7 +23,7 @@ public class Monitor.GPUNvidia : IGPU, Object {

public int nvidia_percentage = 0;

public char *nvidia_used = "";
public char * nvidia_used = "";

public bool nvidia_resources_temperature;

Expand All @@ -34,7 +34,7 @@ public class Monitor.GPUNvidia : IGPU, Object {
public X.Display nvidia_display;

construct {
// session_manager = get_sessman ();
// session_manager = get_sessman ();
nvidia_display = new X.Display ();
}

Expand All @@ -45,7 +45,7 @@ public class Monitor.GPUNvidia : IGPU, Object {
0,
NV_CTRL_GPU_CORE_TEMPERATURE,
&nvidia_temperature
);
);

if (!nvidia_resources_temperature) {
warning ("Could not query NV_CTRL_GPU_CORE_TEMPERATURE attribute!\n");
Expand All @@ -59,11 +59,11 @@ public class Monitor.GPUNvidia : IGPU, Object {
0,
NV_CTRL_USED_DEDICATED_GPU_MEMORY,
&nvidia_memory_vram_used
);
);

if (!nvidia_resources_vram_used) {
warning ("Could not query NV_CTRL_USED_DEDICATED_GPU_MEMORY attribute!\n");
return ;
return;
}

nvidia_resources_used = NVCtrl.XNVCTRLQueryTargetStringAttribute (
Expand All @@ -73,30 +73,39 @@ public class Monitor.GPUNvidia : IGPU, Object {
0,
NV_CTRL_STRING_GPU_UTILIZATION,
&nvidia_used
);
);

// var str_used = (string)nvidia_used;
nvidia_percentage = int.parse (((string)nvidia_used).split_set ("=,")[1]);
nvidia_memory_percentage = int.parse (((string)nvidia_used).split_set ("=,")[3]);
nvidia_percentage = int.parse (((string) nvidia_used).split_set ("=,")[1]);
nvidia_memory_percentage = int.parse (((string) nvidia_used).split_set ("=,")[3]);
debug ("USED_GRAPHICS: %d%\n", nvidia_percentage);
debug ("USED_MEMORY: %d%\n", nvidia_memory_percentage);

if (!nvidia_resources_used) {
warning ("Could not query NV_CTRL_STRING_GPU_UTILIZATION attribute!\n");
return ;
return;
}

}

private void update_temperature () { temperature = nvidia_temperature; }
private void update_temperature () {
temperature = nvidia_temperature;
}

private void update_memory_vram_used () { memory_vram_used = (double) nvidia_memory_vram_used; }
private void update_memory_vram_used () {
memory_vram_used = (double) nvidia_memory_vram_used;
}

private void update_memory_vram_total () { }
private void update_memory_vram_total () {
}

private void update_memory_percentage () { memory_percentage = nvidia_memory_percentage; }
private void update_memory_percentage () {
memory_percentage = nvidia_memory_percentage;
}

private void update_percentage () { percentage = nvidia_percentage; }
private void update_percentage () {
percentage = nvidia_percentage;
}

public void update () {
update_nv_resources ();
Expand All @@ -105,4 +114,5 @@ public class Monitor.GPUNvidia : IGPU, Object {
update_memory_percentage ();
update_percentage ();
}

}
3 changes: 2 additions & 1 deletion src/Resources/GPU/IGPU.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public interface Monitor.IGPU : Object {
public abstract SessionManager? session_manager { get; public set; }
public abstract SessionManager ? session_manager { get; public set; }

public abstract Gee.HashMap<string, HwmonTemperature> hwmon_temperatures { get; set; }

Expand Down Expand Up @@ -44,4 +44,5 @@ public interface Monitor.IGPU : Object {
}
return content;
}

}

0 comments on commit 1e0645d

Please sign in to comment.