From a46caa6c2130f30e6dd4bcbdaa8316febe708490 Mon Sep 17 00:00:00 2001 From: TheMohawkNinja Date: Sun, 9 Oct 2022 22:18:25 -0400 Subject: [PATCH] Minor spelling changes and threaded nitrogen call for troubleshooting --- WallFade.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/WallFade.cpp b/WallFade.cpp index ea77ced..44be395 100644 --- a/WallFade.cpp +++ b/WallFade.cpp @@ -220,6 +220,17 @@ void updateTermColors() system(("echo "+avgRHex[s]+avgGHex[s]+avgBHex[s]+" >> "+configpath+"TermColors").c_str()); } } +void setBackground(std::string h, std::string p, std::string i) +{ + if(i!="") + { + system(("nitrogen --head="+h+" --set-scaled "+p+".cache/transition"+i+".jpg").c_str()); + } + else + { + system(("nitrogen --head="+h+" --set-scaled "+p).c_str()); + } +} void foregroundColorSet(int s) { //Make 30*30 sample space from image @@ -613,7 +624,7 @@ int main(int argc, char **argv) readstream.open(picpath+".cache/.pics"); if(readstream.fail()) { - output(stderr,"ERROR: Unable to open \'%s.cache/,pics\'. Error code: %d\n",picpath.c_str(),errno); + output(stderr,"ERROR: Unable to open \'%s.cache/.pics\'. Error code: %d\n",picpath.c_str(),errno); } else { @@ -628,7 +639,7 @@ int main(int argc, char **argv) readstream.open(picpath+".cache/.pics"); if(readstream.fail()) { - output(stderr,"ERROR: Unable to open \'%s.cache/,pics\'. Error code: %d\n",picpath.c_str(),errno); + output(stderr,"ERROR: Unable to open \'%s.cache/.pics\'. Error code: %d\n",picpath.c_str(),errno); } else { @@ -749,11 +760,13 @@ int main(int argc, char **argv) output(stdout,"Fading new image in on %d\n",S); for (int i=0; i<=steps; i++) { - gettimeofday(¤tTime, NULL); - bgPaintTime=(currentTime.tv_sec*1000)+(currentTime.tv_usec/1000); - system(("nitrogen --head="+to_string(S)+" --set-scaled "+picpath+".cache/transition"+to_string(i)+".jpg").c_str()); - gettimeofday(¤tTime, NULL); - bgPaintTime=((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000))-bgPaintTime; + //gettimeofday(¤tTime, NULL); + //bgPaintTime=(currentTime.tv_sec*1000)+(currentTime.tv_usec/1000); + std::thread setBackgroundThread(setBackground, to_string(S), picpath, to_string(i)); + setBackgroundThread.detach(); + //system(("nitrogen --head="+to_string(S)+" --set-scaled "+picpath+".cache/transition"+to_string(i)+".jpg").c_str()); + //gettimeofday(¤tTime, NULL); + //bgPaintTime=((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000))-bgPaintTime; if(fadeForeground) { @@ -797,11 +810,13 @@ int main(int argc, char **argv) } } - gettimeofday(¤tTime, NULL); - bgPaintTime=(currentTime.tv_sec*1000)+(currentTime.tv_usec/1000); - system(("nitrogen --head="+to_string(S)+" --set-scaled "+newpic).c_str()); - gettimeofday(¤tTime, NULL); - bgPaintTime=((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000))-bgPaintTime; + //gettimeofday(¤tTime, NULL); + //bgPaintTime=(currentTime.tv_sec*1000)+(currentTime.tv_usec/1000); + //system(("nitrogen --head="+to_string(S)+" --set-scaled "+newpic).c_str()); + std::thread setBackgroundThread(setBackground, to_string(S), newpic, ""); + setBackgroundThread.detach(); + //gettimeofday(¤tTime, NULL); + //bgPaintTime=((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000))-bgPaintTime; if(fadeForeground) {