Commit 6e2a6d4b authored by diesys's avatar diesys 🎈

try to clean code add img folder

parent 6cf20766
......@@ -2,83 +2,112 @@
import sys, re
# import getpass #useful for unit systemd
version = "0.5e"
version = "0.6a"
actual_bl = open('/sys/class/backlight/intel_backlight/brightness', 'r+')
max_bl = open('/sys/class/backlight/intel_backlight/max_brightness', 'r')
state = {'actual': int(actual_bl.read()), 'max': int(max_bl.read()), 'verbose': False, 'changed': False, 'actual_info': ''}
percentize = 100/state['max']
state = {'actual': int(actual_bl.read()), 'max': int(max_bl.read()), 'verbose': False, 'changed': False, 'actual_info': '', 'invalid_option': True}
state['new'] = state['actual']
percentize = 100/state['max']
state['actual_pc'] = int(state['actual'] * percentize)
state['actual_info'] = str(int(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_std_pc = 4 #unita' standard di aumento/decremento in percentuale
shift_factor = shift_std_pc * shift_one_pc #fattore moltiplicativo non in percentuale
argvs = len(sys.argv)
help = "Intel Black Light Util · v" + version + "\nPlease insert a valid percentage or use inc/dec (i/d) options (optionally indicating the shift)\nExample: \"ibl d 20\" #decreases the blacklight of 20%, default is 4%"
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"
unit = "[Unit]\nDescription=Intel BackLight Util, changes owner of /sys/class/blacklight/intel_blacklight/brightness\n\n[Service]\nExecStart=/usr/bin/chown jake:wheel /sys/class/backlight/intel_backlight/brightness\n\n[Install]\nWantedBy=multi-user.target\n"
#### todo
# rifare help
# option for creating unit and enabling/disabling
# capability to create keybindings, tty use or something not working with the DE
### percentuale sbagliata
### FARE UNA REGEX ALL'INIZIO E POI LE SOTTOSELEZIONI CON LE PIU SEMPLICI
# === futuro
# = option for creating unit and enabling/disabling
# = capability to create keybindings, tty use or something not working with the DE
def updateState(new_brightness):
new_brightness = int(new_brightness)
if(new_brightness != state['actual_pc']):
if(new_brightness <= 0):
state['new'] = 1
elif(new_brightness < 100):
state['new'] = min(new_brightness * shift_one_pc, state['max'])
elif(new_brightness == 100):
state['new'] = state['max']
state['changed'] = True
else:
state['changed'] = False
def update_state(actual_brightness, new_brightness):
state['actual'] = int(actual_brightness)
state['actual_pc'] = int(state['actual'] * percentize)
state['new'] = int(new_brightness)
state['new_pc'] = int(state['new'] * percentize)
state['new_info'] = str(state['new_pc']) + '% (' + str(state['new']) + '/' + str(state['max']) + ')'
state['changed'] = True
if(argvs == 2):
option = sys.argv[1]
if(re.search(r"[v]+", option)): ##verbose
state['verbose'] = True
state['actual_pc'] = int(state['actual'] * percentize)
if(re.search(r"[d]|[dec]", option)):
tmp = state['actual'] - shift_factor
state['new'] = max(1, tmp)
update_state(int(state['actual']), int(state['new']))
elif(re.search(r"[i]|[inc]", option)):
tmp = state['actual'] + shift_factor
state['new'] = min(state['max'], tmp)
update_state(int(state['actual']), int(state['new']))
else:
if(re.search(r"[0-9]+", option)):
perc = int(re.findall(r"[0-9]+", option)[0])
if(perc <= 0):
state['new'] = 1
elif(perc < 100):
state['new'] = min(perc * shift_one_pc, state['max'])
elif(perc == 100):
state['new'] = state['max']
else:
print(help)
if not (state['new'] == state['actual']):
update_state(state['actual'], int(state['new']))
elif(argvs == 3):
option = sys.argv[1]
increment_pc = int(sys.argv[2]) * shift_one_pc
if(option == 'dec' or option == 'd'):
state['new'] = max(1, state['actual'] - increment_pc)
update_state(int(state['actual']), int(state['new']))
elif(option == 'inc' or option == 'i'):
state['new'] = min(state['max'], state['actual'] + increment_pc)
update_state(int(state['actual']), int(state['new']))
else:
print(help)
state['invalid_option'] = False
verboseOut() ## debug
if state['verbose']:
def verboseOut():
if state['changed']:
print("old: ", state['actual_info'])
print("new: ", state['new_info'])
else:
print("actual: ", state['actual_info'])
def decrease(percentage=shift_std_pc):
updateState(int(state['actual'] - shift_one_pc * percentage))
print(int(state['actual'] - shift_one_pc * percentage))
def increase(percentage=shift_std_pc):
updateState(int(state['actual'] + shift_one_pc * percentage))
print(int(state['actual'] + shift_one_pc * percentage))
###
if(len(sys.argv) == 2): ## getting parameters if exist
option = sys.argv[1]
if(re.search(r"^[v]{0,1}[100]{1}$|^[100]{1}[v]{0,1}$|^[v]{0,1}[0-9]{1,2}$|^[0-9]{1,2}[v]{0,1}$", option)): ## percentage
input_number = re.findall(r"100|[0-9]{0,2}", option)
if(input_number[0]):
# setPercent(input_number[0])
updateState(input_number[0])
elif(input_number[1]):
# setPercent(input_number[1])
updateState(input_number[1])
if(re.search(r"[v]{1}", option)): ## verbose
verboseOut()
if(re.search(r"^[v]{0,1}d$|^d[v]{0,1}$|^[v]{0,1}dec$|^dec[v]{0,1}$", option)): ## decrease bl by a step
decrease()
# print(re.findall(r"^d$", option)[0])
if(re.search(r"[v]{1}", option)): ## verbose
verboseOut()
if(re.search(r"^d[0-9]{1,2}$|^dec[0-9]{1,2}$", option)): ## dec bl by percentage
decrease(int(re.findall(r"[0-9]{1,2}", option)[0]))
if(re.search(r"[v]{1}", option)): ## verbose
verboseOut()
if(re.search(r"^i$|^inc$", option)): ## increase bl by a step
increase()
if(re.search(r"[v]{1}", option)): ## verbose
verboseOut()
if(re.search(r"^i[0-9]{1,2}$|^inc[0-9]{1,2}$", option)): ## inc bl by percentage
increase(int(re.findall(r"[0-9]{1,2}", option)[0]))
if(re.search(r"[v]{1}", option)): ## verbose
verboseOut()
if(re.search(r"^a$|^act$", option)): ## see actual bl
state['invalid_option'] = False
verboseOut()
if(state['invalid_option']):
print(help)
actual_bl.write(str(state['new']))
actual_bl.close()
actual_bl.close()
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg2"
width="400"
height="400"
viewBox="0 0 400 400"
sodipodi:docname="iblu_logo.svg"
inkscape:version="0.92.2 2405546, 2018-03-11"
inkscape:export-filename="/home/jake/code/iblu/img/iblu_logo.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="708"
id="namedview4"
showgrid="false"
inkscape:zoom="0.90817524"
inkscape:cx="127.06449"
inkscape:cy="215.45802"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g832"
inkscape:snap-bbox="true"
inkscape:object-paths="true"
inkscape:snap-intersection-paths="true"
inkscape:snap-smooth-nodes="true" />
<path
style="opacity:1;fill:#ffcc04;fill-opacity:1;stroke:none;stroke-width:1.97400987;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.10526315"
d="m 218.73438,55.376953 c -7.30457,0.317516 -17.02471,33.364642 -24.35743,34.400391 -7.33272,1.035756 -20.11809,-28.83392 -27.35351,-27.097656 -7.23543,1.736264 -5.53255,34.264813 -12.54688,36.671874 -7.01433,2.407078 -30.24475,-22.73395 -36.91797,-19.697265 -4.84209,2.388903 -2.19473,33.064843 -0.44269,45.356923 l 1.96808,-3.41552 c 0.90755,-0.75172 2.0946,-1.60019 3.67579,-2.57812 19.68125,-12.17244 34.63888,-17.34575 52.85742,-23.265627 18.07376,-4.864891 37.38623,-7.481368 56.61328,-7.283203 13.18105,0.135852 26.31925,1.601518 38.99414,4.564453 -3.4935,-6.247733 4.20823,-33.769562 -2.05859,-34.792969 -6.87589,-1.12287 -27.35446,30.193261 -34.50586,29.78711 -7.1514,-0.406152 -8.62124,-32.967911 -15.92578,-32.650391 z m 95.51953,15.552735 c -6.47813,-0.587801 -29.99924,20.20502 -39.19532,23.050781 10.29505,2.676399 20.25056,6.367861 29.62891,11.185551 0.70917,-8.448284 15.34773,-31.944817 10.19531,-34.087895 -0.18683,-0.07771 -0.3969,-0.127387 -0.6289,-0.148437 z m 37.06836,21.666015 c -0.20928,-0.0085 -0.43471,-0.0052 -0.67383,0.0098 -7.77661,0.486671 -30.91626,12.978947 -40.97656,15.263667 7.97345,4.54392 15.4822,9.94592 22.36718,16.2793 4.8418,-8.95902 24.58491,-28.097531 20.72852,-31.134764 -0.32864,-0.25883 -0.8175,-0.392464 -1.44531,-0.417969 z m 24.92968,29.044917 c -8.85046,0.28338 -29.53525,6.38154 -39.5625,7.25196 5.64636,6.40058 9.85068,13.80545 12.74414,21.77344 6.43154,-7.75062 33.42068,-24.15065 30.80664,-28.11329 -0.47668,-0.7226 -1.90495,-0.97881 -3.98828,-0.91211 z m -25.33007,33.51368 c 7.67306,26.04691 2.05701,57.05593 -13.5254,79.01172 -5.43724,0.49988 -9.21992,-0.87408 -14.42087,13.6115 17.12298,-8.46486 53.00342,-0.35029 62.73923,-12.85955 2.56148,-5.4174 -36.31394,-16.23629 -34.67187,-21.75391 1.64207,-5.51761 45.55737,-11.63282 46.25195,-17.15625 0.69457,-5.52342 -42.15708,-7.868 -42.42187,-13.30273 -0.26481,-5.43473 41.77434,-19.7704 40.55468,-25.02344 -1.06133,-4.57122 -34.43777,-0.40393 -44.50585,-2.52734 z m -275.702783,3.81194 c -0.289124,0.34175 -2.113894,-1.63445 -2.819582,-1.27592 -9.627336,4.89128 -55.812248,11.56885 -58.172953,16.56163 -2.56147,5.41739 36.313945,16.2363 34.671876,21.75391 -1.64207,5.51761 -45.5554205,11.63282 -46.2500005,17.15625 -0.69457,5.52342 42.1551215,7.86801 42.4199215,13.30273 0.26479,5.43474 -41.772374,19.7704 -40.552734,25.02344 1.21966,5.25304 45.125677,-1.03616 47.279297,3.94531 2.15363,4.98148 -35.142547,26.55893 -32.091797,31.1836 3.05075,4.62467 45.020326,-9.86842 48.916016,-5.67969 3.89568,4.18874 -26.119283,31.53762 -21.445313,35.21875 4.67396,3.68114 41.848443,-18.03047 47.220703,-14.91992 5.37226,3.11054 -15.312624,34.36873 -9.333984,36.85547 5.97864,2.48673 35.821963,-24.961 42.304683,-23.14063 6.48273,1.82038 -3.46572,34.85564 3.41016,35.97852 6.87589,1.12286 27.35641,-30.19326 34.50781,-29.78711 7.1514,0.40615 8.61928,32.9679 15.92383,32.65039 7.30455,-0.31751 17.02469,-33.36464 24.35742,-34.40039 7.33272,-1.03575 20.1181,28.83196 27.35352,27.0957 7.23544,-1.73627 5.53254,-34.2648 12.54687,-36.67187 7.01434,-2.40708 30.24475,22.73394 36.91797,19.69726 6.67322,-3.03669 -6.33509,-32.82901 -0.11719,-36.44336 6.21794,-3.61435 38.31055,15.08525 43.9668,10.95508 4.74014,-3.46124 -8.35834,-36.51126 -10.62215,-44.98824 -8.15921,10.84971 -31.25672,32.37836 -42.88957,36.01754 -39.12136,12.23855 -80.22386,18.12702 -121.09375,15.94726 -41.64874,-2.79585 -91.211799,-21.11264 -102.951169,-65.69726 -7.045965,-26.81368 9.454366,-66.15794 26.112135,-88.0346 z"
id="path834"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssccccccscssscccccccccccccccccccccccccccsscccssccccccsssssccccsccccc" />
<g
id="g832"
transform="matrix(2.0143774,0,0,2.0143774,-202.93652,-202.82783)">
<path
sodipodi:nodetypes="ccsssccsc"
inkscape:connector-curvature="0"
id="path1227"
d="m 176.01651,255.08132 c -20.67574,-1.38795 -45.28058,-10.48095 -51.10837,-32.61415 -3.92577,-14.93965 0.35471,-31.8561 11.05705,-42.84705 1.91434,-1.96595 2.80709,-0.8972 1.91421,1.2457 -4.35051,10.44135 -9.64897,20.96485 -7.45506,33.16575 3.33016,18.5199 21.85394,26.9907 38.41941,28.85765 29.75631,3.1915 60.34692,-2.99825 86.82133,-16.87825 8.74563,12.09525 -10.63712,18.3706 -19.53363,21.15375 -19.42107,6.0756 -39.82585,8.9987 -60.11494,7.9166 z"
style="fill:#723e00;stroke-width:0.30424568;fill-opacity:1" />
<path
sodipodi:nodetypes="sccsscscs"
inkscape:connector-curvature="0"
id="path1199"
d="m 257.35741,219.61732 c 0.55159,-9.40185 6.07406,-5.11485 11.08769,-23.1516 2.39718,-13.13885 -3.30547,-27.44585 -15.25942,-33.99265 -26.08134,-16.82654 -60.45572,-13.90489 -87.25579,-0.8541 -4.62689,2.25315 -10.96455,2.31155 -4.24414,-1.8449 9.77039,-6.04278 17.19606,-8.61139 26.24031,-11.5502 26.10147,-7.0257 57.40522,-4.60319 77.7386,14.1752 14.60948,13.4922 13.78696,38.7381 2.57346,54.53805 -2.58695,2.9951 -11.50317,13.2902 -10.88071,2.6802 z"
style="fill:#723e00;stroke-width:0.30036318;fill-opacity:1" />
<g
transform="matrix(0.5108565,-0.02019998,0.02019998,0.5108565,476.34803,-324.5377)"
id="g1377"
style="fill:#190e00;fill-opacity:1">
<path
inkscape:connector-curvature="0"
id="path1221"
d="m -670.12159,1043.7541 c -7.5368,-2.0665 -14.02429,-9.0739 -12.90075,-17.302 -0.35703,-18.9113 -0.31823,-37.82794 -0.4782,-56.74177 6.23887,0 12.47773,0 18.7166,0 0,24.88892 0,49.77787 0,74.66677 -1.79407,-0.035 -3.60356,-0.1009 -5.33765,-0.623 z"
style="fill:#190e00;stroke-width:0.66666669;fill-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1203"
d="m -484.71827,1006.6782 c 0,12.3441 0,24.6881 0,37.0322 -15.25615,-0.2703 -30.53956,0.088 -45.77286,-0.7771 -9.60596,-1.9578 -16.0801,-12.0385 -15.15785,-21.617 -0.32129,-17.2212 -0.31245,-34.44683 -0.46829,-51.67018 6.46633,0 12.93267,0 19.399,0 0,18.25639 0,36.51278 0,54.76918 2.03161,1.7066 3.47252,4.839 6.60099,3.8975 5.35523,0 10.71045,0 16.06568,0 0,-19.5556 0,-39.11112 0,-58.66668 6.44444,0 12.88889,0 19.33333,0 0,12.34403 0,24.68805 0,37.03208 z"
style="fill:#190e00;stroke-width:0.66666669;fill-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1197"
d="m -565.45061,1041.9326 c -7.9584,-2.3828 -13.40216,-10.4908 -12.34633,-18.7848 -0.48874,-28.26565 -0.22585,-56.53837 -0.32037,-84.80731 6.33333,0.1233 12.66667,0.24662 19,0.36994 0.11381,34.77779 0.22763,69.55557 0.34146,104.33337 -2.28169,0.078 -4.52545,-0.3427 -6.67476,-1.1112 z"
style="fill:#190e00;stroke-width:0.66666669;fill-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1179"
d="m -683.45061,950.37709 c 0,-3.11111 0,-6.22222 0,-9.33333 6.22222,0 12.44445,0 18.66667,0 0,6.22222 0,12.44445 0,18.66667 -6.22222,0 -12.44445,0 -18.66667,0 0,-3.11111 0,-6.22223 0,-9.33334 z"
style="fill:#190e00;stroke-width:0.66666669;fill-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1359"
d="m -652.11719,938.33984 c 0.22546,29.99544 -0.51549,59.97407 0.58417,89.96876 1.17828,9.8315 11.70609,15.8254 21.00324,14.7076 8.88105,-0.3617 17.88473,0.6012 26.68331,-0.7663 8.74081,-3.3248 13.6434,-12.9006 12.69018,-22.0003 -0.16585,-12.0845 1.23472,-24.36315 -0.96095,-36.31359 -2.44778,-8.63263 -11.24058,-14.98152 -20.2952,-13.87974 -6.75719,-0.32128 -14.1327,0.1023 -20.60298,-0.41029 -0.0339,-10.31185 -0.0677,-20.62369 -0.10157,-30.93554 -6.33339,-0.1238 -12.66679,-0.24733 -19.0002,-0.3706 z m 19.33399,46.70313 c 6.25586,0 12.51172,0 18.76758,0 1.70679,2.03195 4.83985,3.47312 3.89843,6.60199 0,10.92364 0,21.84734 0,32.77104 -2.03296,1.7052 -3.47349,4.838 -6.60198,3.8965 -5.35468,0 -10.70935,0 -16.06403,0 0,-14.4232 0,-28.84635 0,-43.26953 z"
style="fill:#190e00;stroke-width:0.66666669;fill-opacity:1" />
</g>
</g>
</svg>
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