Commit 3c61f2bc authored by diesys's avatar diesys 🎈

effective percentage fix

parent 73b3d0b9
......@@ -9,12 +9,12 @@ max_bl = open('/sys/class/backlight/intel_backlight/max_brightness', 'r')
state = {'actual': int(actual_bl.read()), 'max': int(max_bl.read()), 'changed': False, 'actual_info': '', 'invalid_option': True}
state['new'] = state['actual']
percentize = 100/state['max']
state['actual_pc'] = math.ceil(int(state['actual']) * percentize)
state['actual_info'] = str(math.ceil(state['actual'] * percentize)) + '% (' + str(state['actual']) + '/' + str(state['max']) + ')'
shift_one_pc = int(state['max'])/100 #unita' percentuale sulla luminosita' massima
shift_std_pc = 4 #unita' standard di aumento/decremento in percentuale
shift_factor = shift_std_pc * shift_one_pc #fattore moltiplicativo non in percentuale
state['actual_pc'] = 0 if (state['actual'] < shift_one_pc-1) else math.ceil(int(state['actual']) * percentize)
state['actual_info'] = str(state['actual_pc']) + '% (' + str(state['actual']) + '/' + str(state['max']) + ')'
help = "Intel Black Light Util · v" + version + "\n\n\t0-100\t\tsets to the given percentage\n\ti (inc)\t\tincreases the actual backlight\n\td (dec)\t\tdecreases the actual backlight\n\ta (act)\t\tshows the actual\n\tv\t\tshows verbose output\n"
......@@ -28,8 +28,8 @@ unit = "[Unit]\nDescription=Intel BackLight Util, changes owner of /sys/class/bl
def updateState(new_percent):
new_percent = int(new_percent)
new_brightness = math.ceil(new_percent * shift_one_pc)
if(new_percent != state['actual_pc']):
new_brightness = math.floor(new_percent * shift_one_pc)
if(state['actual'] - new_brightness < 1): ## to prevent approx errors
if(new_percent <= 0):
new_brightness = 1
elif(new_percent < 100):
......@@ -42,7 +42,7 @@ def updateState(new_percent):
else:
state['changed'] = False
state['new'] = int(new_brightness)
state['new'] = max(int(new_brightness), 1) ## to prevent blank screen
state['new_pc'] = new_percent
state['new_info'] = str(state['new_pc']) + '% (' + str(state['new']) + '/' + str(state['max']) + ')'
state['invalid_option'] = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment