Skip to content
Snippets Groups Projects
Commit ba99c94d authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

I3 & CPU Add tool to set cpu frequenci.

parent 93db4c6d
No related branches found
No related tags found
No related merge requests found
const int adrlen = 2;
const char adr [adrlen][1000] =
{
"/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness",
"/sys/devices/pci0000:00/0000:00:02.0/drm/card1/card1-eDP-1/intel_backlight/brightness"
};
#!/bin/bash
cd "$(dirname "$0")"
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
g++ ./cpuF.c -o /usr/bin/cpuF
chmod u+s /usr/bin/cpuF
cp ./cpuFGUI.sh /usr/bin/cpuFGUI
chmod o+x /usr/bin/cpuFGUI
if [ "$1" == no ];
then
exit;
fi
sudo pacman -S cpupower
gnome-terminal --window-with-profile=123 -e "bash -i -c \"battery;read -p \\\"Press\\\"\"";i3-msg floating enable
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
#include "adr.h"
const int lightMin = 2;
const int lightMax = 937;
int main(int argc,char ** argv)
{
if(argc<=2) return 100;
setuid(0);
if(argv[1][0]=='H')
{
FILE * f = fopen(adr[adri],"w");
if(!f) goto nextAdr;
fprintf(f,"%d",atoi(argv[2]));
fclose(f);
return 0;
}
double argv2 = atof(argv[2]);
double light;
if(argv[1][0]=='=')
light = argv2;
else
{
FILE * f = fopen(adr[adri],"r");
if(!f) goto nextAdr;
fprintf(f,"%d",atoi(argv[2]));
int realAct;
fscanf(f,"%d",&realAct);
if(realAct<light) realAct=lightMin;
double act=log(realAct);
if(argv[1][0]=='+')
light = act+argv2;
else
if(argv[1][0]=='-')
light = act-argv2;
else return 100;
fclose(f);
}
int notInLimit=0;
double realLight=pow(M_E,light);
if(realLight>lightMax)
{
realLight=lightMax;
notInLimit=1;
}
if(realLight<lightMin)
{
realLight=lightMin;
notInLimit=1;
}
int intLight = realLight+0.7;
FILE * f = fopen(adr[adri],"w");
if(!f) goto nextAdr;
//printf("light=%d\n",intLight);
fprintf(f,"%d",intLight);
fclose(f);
//char exe [1000];
//sprintf( exe,"echo %d > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness",light);
//system(exe);
return notInLimit;
}
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
const double redMin = 1000;
const double redMax = 10000;
const double gammaMin = 0.1;
const double gammaMax = 2;
int main(int argc,char ** argv)
{
if(argc<2) return 100;
setuid(0);
long long f = atoll(argv[1]);
f *= 1000;
char scall[1000];
sprintf(scall,"cpupower frequency-set --max %lld",f);
system(scall);
}
notify-send "CPU FREQUENCI $1" "\n$(cpupower -c all frequency-info -f -m)" -h string:x-canonical-private-synchronous:anything
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
#include "adr.h"
const int lightMin = 2;
const int lightMax = 937;
int main(int argc,char ** argv)
{
setuid(0);
for(int adri=0;adri<adrlen;adri++)
{
{
FILE * f = fopen(adr[adri],"r");
if(!f) goto nextAdr;
int realAct;
fscanf(f,"%d",&realAct);
double act=log(realAct);
if(act<0) act = 0;
printf("%d%% %d\n[",int(100*act/log(lightMax)+0.5),realAct);
for(double i=0;i<log(lightMax);i+=0.3)
printf("%s",act<i?"−":"+");
printf("]");
fclose(f);
return 0;
}
nextAdr:;
}
return 1;
}
......@@ -281,6 +281,12 @@ mode "System modifikator"
bindsym $mod+Escape mode "default"
bindsym k exec "setxkbmap us,cz -variant ,ucw -option grp:caps_switch"
bindsym p exec cpuFGUI
bindsym o exec "cpuF 5000; cpuFGUI 'SET TO 5000'"
bindsym i exec "cpuF 1500; cpuFGUI 'SET TO 1500'"
bindsym u exec "cpuF 800; cpuFGUI 'SET TO 800'"
bindsym y exec "cpuF 400; cpuFGUI 'SET TO 400'"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment