Skip to content

Commit

Permalink
shell animation changes speed depending on CPU usage from now
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolat committed Dec 19, 2021
1 parent 93df670 commit 5912c17
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 31 deletions.
87 changes: 71 additions & 16 deletions ghost/master/main.azr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ int unloaded = 0;
int display_width = -1;
int display_height = -1;
int dance = 0;
int dance_speed = 1;
int saved_dance = 0;
int maxscope = 0;
int stayontop = 0;
Expand Down Expand Up @@ -79,25 +80,29 @@ OnDisplayChange(dict ref)
display_height = ref["Reference2"];
}

string OnFirstBoot() { return show_scope_all() + "\e"; }
string OnBoot() { return show_scope_all() + "\e"; }
string OnGhostChanged() { return show_scope_all() + "\e"; }
string OnShellChanged() { return show_scope_all() + "\e"; }
string OnWindowStateRestore() { return show_scope_all() + "\e"; }
string OnFirstBoot() { return dance_all() + "\e"; }
string OnBoot() { return dance_all() + "\e"; }
string OnGhostChanged() { return dance_all() + "\e"; }
string OnShellChanged() { return dance_all() + "\e"; }
string OnWindowStateRestore() { return dance_all() + "\e"; }
string OnSurfaceRestore() { return ""; }
string OnClose()
{
dance = 0;
unloaded = 1;
return "\_w[1000]\-\e";
}
string show_scope_all()
string dance_all()
{
dance = 1;
return show_scope_all();
}
string show_scope_all()
{
string s;
for (int i = 0; i <= maxscope; i++)
{
s += "\p[" + i + "]\s[" + (10 * i) + "]";
s += "\p[" + i + "]\s[" + (10 * i) + "]\i[" + dance_speed + "]";
}
return s;
}
Expand All @@ -119,7 +124,7 @@ string OnUpdateComplete(dict ref)
if (reason == "none")
dance = saved_dance;
else if (reason == "changed")
s += show_scope_all();
s += dance_all();
s += show_info("Network Update", reason) + "\e";
return s;
}
Expand All @@ -139,9 +144,19 @@ string OnMouseDoubleClick(dict ref)
{
dance = !dance;
string s;
for (int i = 0; i <= maxscope; i++)
if (dance)
{
s += "\p[" + i + "]\i[" + dance + "]";
for (int i = 0; i <= maxscope; i++)
{
s += "\p[" + i + "]\i[" + dance_speed + "]";
}
}
else
{
for (int i = 0; i <= maxscope; i++)
{
s += "\p[" + i + "]\i[0]";
}
}
return s + "\e";
}
Expand Down Expand Up @@ -202,6 +217,18 @@ TH_CheckCPU()
int cpu_usage = d["Result"];
int offset = 30;
wait_dance = (1.0 * offset + 50 - (cpu_usage / 2)) / 1000;
int next_speed;
if (cpu_usage < 25)
next_speed = 1;
else if (cpu_usage < 50)
next_speed = 2;
else
next_speed = 3;
if (dance_speed != next_speed)
{
dance_speed = next_speed;
_speak(show_scope_all());
}
}
_sleep(CHECK_CPU_INTERVAL);
}
Expand Down Expand Up @@ -406,18 +433,46 @@ make_surfaces_txt(int scope)
+ "element0,base," + ns + "/0.png,0,0" + sep
+ "" + sep
+ "animation0.interval,never" + sep
+ "animation0.pattern0,stop,2" + sep
+ "animation0.pattern0,stop,11" + sep
+ "animation0.pattern1,stop,12" + sep
+ "animation0.pattern2,stop,13" + sep
+ "" + sep
+ "animation1.interval,never" + sep
+ "animation1.pattern0,start,2" + sep
+ "animation1.pattern0,stop,12" + sep
+ "animation1.pattern1,stop,13" + sep
+ "animation1.pattern2,start,11" + sep
+ "" + sep
+ "animation2.interval,never" + sep
+ "animation2.pattern0,stop,11" + sep
+ "animation2.pattern1,stop,13" + sep
+ "animation2.pattern2,start,12" + sep
+ "" + sep
+ "animation2.interval,always" + sep;
+ "animation3.interval,never" + sep
+ "animation3.pattern0,stop,11" + sep
+ "animation3.pattern1,stop,12" + sep
+ "animation3.pattern2,start,13" + sep
+ "" + sep;
text += "animation11.interval,always" + sep;
for (int i = 0; i < 9; i++)
{
text += "animation2.pattern" + i + ",replace,1" + ns + fill2(i + 1) + ",50,0,0" + sep;
text += "animation11.pattern" + i + ",replace,1" + ns + fill2(i + 1) + ",50,0,0" + sep;
}
text += "animation2.pattern9,replace," + (10 * scope) + ",50,0,0" + sep
+ "}" + sep
text += "animation11.pattern9,replace," + (10 * scope) + ",50,0,0" + sep;
text += "" + sep;
text += "animation12.interval,always" + sep;
for (int i = 0; i < 9; i++)
{
text += "animation12.pattern" + i + ",replace,1" + ns + fill2(i + 1) + ",40,0,0" + sep;
}
text += "animation12.pattern9,replace," + (10 * scope) + ",40,0,0" + sep;
text += "" + sep;
text += "animation13.interval,always" + sep;
for (int i = 0; i < 9; i++)
{
text += "animation13.pattern" + i + ",replace,1" + ns + fill2(i + 1) + ",30,0,0" + sep;
}
text += "animation13.pattern9,replace," + (10 * scope) + ",30,0,0" + sep;
text += "}" + sep
+ "" + sep;
for (int i = 0; i < 9; i++)
{
Expand Down
64 changes: 51 additions & 13 deletions shell/master/surfaces00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,60 @@ surface0
element0,base,00/0.png,0,0

animation0.interval,never
animation0.pattern0,stop,2
animation0.pattern0,stop,11
animation0.pattern1,stop,12
animation0.pattern2,stop,13

animation1.interval,never
animation1.pattern0,start,2
animation1.pattern0,stop,12
animation1.pattern1,stop,13
animation1.pattern2,start,11

animation2.interval,always
animation2.pattern0,replace,10001,50,0,0
animation2.pattern1,replace,10002,50,0,0
animation2.pattern2,replace,10003,50,0,0
animation2.pattern3,replace,10004,50,0,0
animation2.pattern4,replace,10005,50,0,0
animation2.pattern5,replace,10006,50,0,0
animation2.pattern6,replace,10007,50,0,0
animation2.pattern7,replace,10008,50,0,0
animation2.pattern8,replace,10009,50,0,0
animation2.pattern9,replace,0,50,0,0
animation2.interval,never
animation2.pattern0,stop,11
animation2.pattern1,stop,13
animation2.pattern2,start,12

animation3.interval,never
animation3.pattern0,stop,11
animation3.pattern1,stop,12
animation3.pattern2,start,13

animation11.interval,always
animation11.pattern0,replace,10001,50,0,0
animation11.pattern1,replace,10002,50,0,0
animation11.pattern2,replace,10003,50,0,0
animation11.pattern3,replace,10004,50,0,0
animation11.pattern4,replace,10005,50,0,0
animation11.pattern5,replace,10006,50,0,0
animation11.pattern6,replace,10007,50,0,0
animation11.pattern7,replace,10008,50,0,0
animation11.pattern8,replace,10009,50,0,0
animation11.pattern9,replace,0,50,0,0

animation12.interval,always
animation12.pattern0,replace,10001,40,0,0
animation12.pattern1,replace,10002,40,0,0
animation12.pattern2,replace,10003,40,0,0
animation12.pattern3,replace,10004,40,0,0
animation12.pattern4,replace,10005,40,0,0
animation12.pattern5,replace,10006,40,0,0
animation12.pattern6,replace,10007,40,0,0
animation12.pattern7,replace,10008,40,0,0
animation12.pattern8,replace,10009,40,0,0
animation12.pattern9,replace,0,40,0,0

animation13.interval,always
animation13.pattern0,replace,10001,30,0,0
animation13.pattern1,replace,10002,30,0,0
animation13.pattern2,replace,10003,30,0,0
animation13.pattern3,replace,10004,30,0,0
animation13.pattern4,replace,10005,30,0,0
animation13.pattern5,replace,10006,30,0,0
animation13.pattern6,replace,10007,30,0,0
animation13.pattern7,replace,10008,30,0,0
animation13.pattern8,replace,10009,30,0,0
animation13.pattern9,replace,0,30,0,0
}

surface10001
Expand Down
4 changes: 2 additions & 2 deletions updates2.dau
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ghost/master/icon/parrot6.ico3db92f3b718c7509a435a7cd23e491dfsize=90022date=2
ghost/master/icon/parrot7.icoeaf555fedda2e5acf391a7b7bba116e5size=90022date=2021-10-12T19:50:42
ghost/master/icon/parrot8.ico7abba324694fc78449abbd211aac9ec6size=90022date=2021-10-12T19:50:42
ghost/master/icon/parrot9.ico982f0bcd117f2c690f986f3bbbf555cesize=90022date=2021-10-12T19:50:42
ghost/master/main.azr929d83e1329392935c5c5504c5fc75aasize=10270date=2021-12-18T14:09:03
ghost/master/main.azr56e37b6c5fed3421d32aee8d3e40c83dsize=11798date=2021-12-19T21:30:04
ghost/master/saori/HandUtil/HandUtil.dlld382e237a4b365a302b281664d9e9d36size=38400date=2011-05-05T18:38:36
ghost/master/saori/HandUtil/HandUtil_readme.txt27422edfad98e1d957cc78f815587a2csize=4501date=2011-05-28T14:47:52
ghost/master/saori/ccpuid/README.txt06095d6d4e02c99e4fedcf12c772f704size=3232date=2010-04-19T23:13:46
Expand All @@ -35,5 +35,5 @@ shell/master/surface0.apng77523cdc0122286554f5677ed39fa7e8size=11791date=2021
shell/master/surface0.pngfd9a12b0369ba5430428bbb1ce5ef47esize=2314date=2021-10-12T19:50:42
shell/master/surface10.png8565865637b749e83ea9f1c875d277bcsize=387date=2021-10-12T19:50:42
shell/master/surfaces.txt5cd37d78f04c448f4634afab4f4870ccsize=44date=2021-10-12T19:50:42
shell/master/surfaces00.txta87fb852822737108df721af670951c7size=1085date=2021-10-12T19:50:42
shell/master/surfaces00.txtcda0eabdbc823379418df49a866d34d1size=2362date=2021-12-19T21:29:21
shell/master/surfacetable.txt6f85b9603084223db95e7cbf5d99b23esize=279date=2021-10-13T13:34:12

0 comments on commit 5912c17

Please sign in to comment.