dotfiles/i3/scripts/lightlevel.cpp
2025-07-20 18:14:55 +02:00

30 lines
653 B
C++

#include <iostream>
int main(int argc, char* argv[]) {
if(argc < 2) return 1;
int current;
std::cin >> current;
int add = 0;
if(argv[1][0] == '+') {
if(current < 6) add = 1;
else if(current < 10) add = 2;
else if(current < 20) add = 5;
else if(current < 40) add = 10;
else if(current < 100) add = 20;
}
else if(argv[1][0] == '-') {
if(current > 40) add = -20;
else if(current > 20) add = -10;
else if(current > 10) add = -5;
else if(current > 6) add = -2;
else if(current > 1) add = -1;
}
else if(argv[1][0] == '=') {
std::cout << current << "%\n";
return 0;
}
else return 2;
std::cout << current+add;
return 0;
}