Skip to content
Snippets Groups Projects
Commit 91490583 authored by JiriKalvoda's avatar JiriKalvoda
Browse files

LIGHT Add gui view and not sudo access.

parent fdbde118
Branches
No related tags found
No related merge requests found
...@@ -166,10 +166,10 @@ if ! shopt -oq posix; then ...@@ -166,10 +166,10 @@ if ! shopt -oq posix; then
. /etc/bash_completion . /etc/bash_completion
fi fi
fi fi
light() # light()
{ # {
sudo sh -c 'echo '$1' > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness' # sudo sh -c 'echo '$1' > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness'
} # }
mkdircd() mkdircd()
{ {
mkdir $1; cd $1 mkdir $1; cd $1
......
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
apt install notify-osd
g++ ./light.c -o /usr/bin/light
chmod u+s /usr/bin/light
g++ ./lightInfo.c -o /usr/bin/lightInfo
chmod u+s /usr/bin/lightInfo
cp ./lightGUI.sh /usr/bin/lightGUI
chmod o+x /usr/bin/lightGUI
File deleted
...@@ -16,6 +16,7 @@ int main(int argc,char ** argv) ...@@ -16,6 +16,7 @@ int main(int argc,char ** argv)
FILE * f = fopen(adr,"w"); FILE * f = fopen(adr,"w");
fprintf(f,"%d",atoi(argv[2])); fprintf(f,"%d",atoi(argv[2]));
fclose(f); fclose(f);
return 0;
} }
double argv2 = atof(argv[2]); double argv2 = atof(argv[2]);
double light; double light;
......
sudo sh -c 'echo '$1' > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness'
notify-send "JAS" "`lightInfo`" -h string:x-canonical-private-synchronous:anything
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
const char adr [] = "/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness";
const int lightMin = 2;
const int lightMax = 937;
int main(int argc,char ** argv)
{
setuid(0);
FILE * f = fopen(adr,"r");
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);
}
sudo sh -c 'echo '$1' > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness'
#echo $1 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment