Skip to content

Instantly share code, notes, and snippets.

@Razikus

Razikus/lxdeBrightness.md

Last active Jul 29, 2018
Embed
What would you like to do?
Scripts for lxde for raise and lower brightness by fn keys

/usr/local/bin/setBrightness

#!/bin/bash
if [ $# -eq 0 ]; then
	if [ ! -f ~/brightness ]; then
		echo "1" > ~/brightness
	fi
	BRIGHT=$(cat ~/brightness)
else
	BRIGHT=$1
	echo "$1" > $HOME/brightness
fi
xrandr --output LVDS-1 --brightness $BRIGHT

/usr/local/bin/raiseBrightness

#!/bin/bash

if [ ! -f ~/brightness ]; then
	echo "1" > ~/brightness
fi
BRIGHT=$(cat ~/brightness)
BRIGHT=$(echo $BRIGHT+0.1 | bc)
echo $BRIGHT > ~/brightness
echo "NEW BRIGHTNESS = $BRIGHT"
xrandr --output LVDS-1 --brightness $BRIGHT

/usr/local/bin/lowerBrightness

#!/bin/bash

if [ ! -f ~/brightness ]; then
	echo "1" > ~/brightness
fi
BRIGHT=$(cat ~/brightness)
BRIGHT=$(echo $BRIGHT-0.1 | bc)
echo $BRIGHT > ~/brightness
echo "NEW BRIGHTNESS = $BRIGHT"
xrandr --output LVDS-1 --brightness $BRIGHT

/home/USER/.config/openbox/lxde-rc.xml new entries in section <keyboard>

<keybind key="XF86MonBrightnessDown">
	  <action name="Execute">
		  <command>lowerBrightness</command>
	  </action>
  </keybind>
  <keybind key="XF86MonBrightnessUp">
	  <action name="Execute">
		  <command>raiseBrightness</command>
	  </action>
  </keybind>

create catalog ~/.config/autostart if not exists and add in ~/.config/autostart file brightness.desktop

[Desktop Entry]
Type=Application
Exec=/usr/local/bin/setbrightness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment