Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyra-scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sebt3
pyra-scripts
Commits
7e704f08
Commit
7e704f08
authored
Sep 25, 2017
by
sebt3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved brightness script
parent
f0381a86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
135 deletions
+59
-135
pyra-brightkey.sh
pyra-brightkey.sh
+59
-135
No files found.
pyra-brightkey.sh
View file @
7e704f08
#!/bin/sh
if
[
$1
=
"screen"
]
;
then
if
[
$2
=
"set"
]
;
then
minbright
=
1
maxbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/max_brightness
)
"
curbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
newbright
=
$(
zenity
--scale
--text
"pick a number"
--min-value
=
$minbright
--max-value
=
$maxbright
--value
=
$curbright
--step
1
)
;
else
newbright
=
$3
fi
if
[
$newbright
]
;
then
if
[
$newbright
-le
$minbright
]
;
then
newbright
=
$minbright
;
fi
if
[
$newbright
-ge
$maxbright
]
;
then
newbright
=
$maxbright
;
fi
echo
$newbright
>
/sys/devices/platform/backlight/backlight/backlight/brightness
fi
elif
[
$2
=
"up"
]
;
then
maxbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/max_brightness
)
"
curbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
if
[
$curbright
=
$maxbright
]
;
then
newbright
=
$maxbright
else
newbright
=
$((
$curbright
+
1
))
fi
else
newbright
=
$((
$curbright
+
$3
))
if
[
$newbright
-gt
$maxbright
]
;
then
newbright
=
$maxbright
fi
fi
echo
$newbright
>
/sys/devices/platform/backlight/backlight/backlight/brightness
elif
[
$2
=
"down"
]
;
then
minbright
=
0
curbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
if
[
"
$curbright
"
=
"
$minbright
"
]
;
then
newbright
=
$minbright
else
newbright
=
$((
$curbright
-
1
))
fi
else
newbright
=
$((
$curbright
-
$3
))
if
[
$newbright
-lt
$minbright
]
;
then
newbright
=
$minbright
fi
fi
echo
$newbright
>
/sys/devices/platform/backlight/backlight/backlight/brightness
elif
[
$2
=
"toggle"
]
;
then
curbright
=
"
$(
cat
/sys/devices/platform/backlight/backlight/backlight/actual_brightness
)
"
if
[
$curbright
=
0
]
;
then
newbright
=
"
$(
cat
/var/lib/pyra/screen-toggle-value
)
"
else
echo
$curbright
>
/var/lib/pyra/screen-toggle-value
newbright
=
0
fi
echo
$newbright
>
/sys/devices/platform/backlight/backlight/backlight/brightness
help
()
{
cat
<<
ENDHELP
$0
{screen|keyboard} {up|down|set|toggle} [value]
ENDHELP
}
case
"
$1
"
in
screen|[sS][Cc][rR]
*
)
FTOG
=
"/var/lib/pyra/screen-toggle-value"
FPAT
=
"/sys/devices/platform/backlight/backlight/backlight"
minbright
=
1
;;
keyboard|[kK][eE][yY]
*
)
FTOG
=
"/var/lib/pyra/keyboard-toggle-value"
FPAT
=
"/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight"
minbright
=
0
;;
*
)
help
"
$0
"
exit
1
;;
esac
FCUR
=
"
$FPAT
/actual_brightness"
FMAX
=
"
$FPAT
/max_brightness"
FSET
=
"
$FPAT
/brightness"
curbright
=
"
$(
cat
"
$FCUR
"
)
"
maxbright
=
"
$(
cat
"
$FMAX
"
)
"
newbright
=
$curbright
case
"
$2
"
in
set
|
[
sS][eE][tT]
)
if
[
!
$3
]
;
then
newbright
=
$(
zenity
--scale
--text
"pick a number"
"--min-value=
$minbright
"
"--max-value=
$maxbright
"
"--value=
$curbright
"
--step
1
)
;
else
newbright
=
$3
fi
elif
[
$1
=
"keyboard"
]
;
then
if
[
$2
=
"set"
]
;
then
minbright
=
0
maxbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/max_brightness
)
"
curbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
newbright
=
$(
zenity
--scale
--text
"pick a number"
--min-value
=
$minbright
--max-value
=
$maxbright
--value
=
$curbright
--step
1
)
;
else
newbright
=
$3
fi
if
[
$newbright
]
;
then
if
[
$newbright
-le
$minbright
]
;
then
newbright
=
$minbright
;
fi
if
[
$newbright
-ge
$maxbright
]
;
then
newbright
=
$maxbright
;
fi
echo
$newbright
>
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
fi
elif
[
$2
=
"up"
]
;
then
maxbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/max_brightness
)
"
curbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
if
[
$curbright
=
$maxbright
]
;
then
newbright
=
$maxbright
else
newbright
=
$((
$curbright
+
1
))
fi
else
newbright
=
$((
$curbright
+
$3
))
if
[
$newbright
-gt
$maxbright
]
;
then
newbright
=
$maxbright
fi
fi
echo
$newbright
>
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
elif
[
$2
=
"down"
]
;
then
if
[
!
$newbright
]
;
then
exit
0
fi
;;
up|[uU][pP]
)
if
[
!
$3
]
;
then
newbright
=
$((
$curbright
+
1
))
else
newbright
=
$((
$curbright
+
$3
))
fi
;;
down|[dD][oO][wW][nN]
)
if
[
!
$3
]
;
then
newbright
=
$((
$curbright
-
1
))
else
newbright
=
$((
$curbright
-
$3
))
fi
;;
toggle|[tT][oO][gG]
*
)
if
[
$curbright
=
0
]
;
then
newbright
=
"
$(
cat
$FTOG
)
"
else
echo
$curbright
>
$FTOG
minbright
=
0
curbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness
)
"
if
[
!
$3
]
;
then
if
[
"
$curbright
"
=
"
$minbright
"
]
;
then
newbright
=
$minbright
else
newbright
=
$((
$curbright
-
1
))
fi
else
newbright
=
$((
$curbright
-
$3
))
if
[
$newbright
-lt
$minbright
]
;
then
newbright
=
$minbright
fi
fi
echo
$newbright
>
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
elif
[
$2
=
"toggle"
]
;
then
curbright
=
"
$(
cat
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/actual_brightness
)
"
if
[
$curbright
=
0
]
;
then
newbright
=
"
$(
cat
/var/lib/pyra/keyboard-toggle-value
)
"
else
echo
$curbright
>
/var/lib/pyra/keyboard-toggle-value
newbright
=
0
fi
echo
$newbright
>
/sys/devices/platform/keyboard-backlight/backlight/keyboard-backlight/brightness
fi
fi
newbright
=
0
fi
;;
*
)
help
"
$0
"
exit
1
;;
esac
[
$newbright
-le
$minbright
]
&&
newbright
=
$minbright
[
$newbright
-ge
$maxbright
]
&&
newbright
=
$maxbright
echo
$newbright
>
$FSET
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment