bbqshift

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

bbqshift

Unread post by machinebacon » Tue Feb 25, 2014 11:38 am

We do need no bloated gtk-redshift do we?

Code: Select all

#!/bin/bash
NR=1
NG=1
NB=1
NL=1
RR=1000
GG=1000
BB=1000
LL=1000
CON=`xrandr -q|grep con|cut -d " " -f 1`
echo Detected connectors are: $CON
echo Which do you want to manipulate?
read MON
clear
echo "rR gG bB to move gamma"
echo "lL to adjust brightness"
echo "s to save, q to reset and quit."
while read -n1 -s; do
	if [ $REPLY = 'R' ]; then
		let RR="$RR+50"
		NR=$(echo "$RR/1000"|bc -l)
		echo "RED increased"
	elif [ $REPLY = 'r' ]; then
		let RR="$RR-50"
		NR=$(echo "$RR/1000"|bc -l)
		echo "RED decreased"
	elif [ $REPLY = 'G' ]; then
		let GG="$GG+50"
		NG=$(echo "$GG/1000"|bc -l)
		echo "GREEN increased"
	elif [ $REPLY = 'g' ]; then
		let GG="$GG-50"
		NG=$(echo "$GG/1000"|bc -l)
		echo "GREEN decreased"
	elif [ $REPLY = 'B' ]; then
		let BB="$BB+50"
		NB=$(echo "$BB/1000"|bc -l)
		echo "BLUE increased"
	elif [ $REPLY = 'b' ]; then
		let BB="$BB-50"
		NB=$(echo "$BB/1000"|bc -l)
		echo "BLUE decreased"
	elif [ $REPLY = 'L' ]; then
		let LL="$LL+50"
		NL=$(echo "$LL/1000"|bc -l)
		echo "BRIGHTNESS increased"
	elif [ $REPLY = 'l' ]; then
		let LL="$LL-50"
		NL=$(echo "$LL/1000"|bc -l)
		echo "BRIGHTNESS decreased"
	elif [ $REPLY = s ]; then
		echo "xrandr --output $MON --gamma $NR:$NG:$NB --brightness $NL" > ~/xrandrconf
		chmod a+x ~/xrandrconf
		echo "Saved as ~/xrandrconf"
		exit 0
	elif [ $REPLY = q ]; then
		xrandr --output $MON --gamma 1.0:1.0:1.0 --brightness 1.0
		exit 0
	fi
xrandr --output $MON --gamma $NR:$NG:$NB --brightness $NL > /dev/null 2>&1
done
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: bbqshift

Unread post by wuxmedia » Tue Feb 25, 2014 12:27 pm

wow.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
ivanovnegro
Minister of Truth
Posts: 5449
Joined: Wed Oct 17, 2012 11:12 pm

Re: bbqshift

Unread post by ivanovnegro » Tue Feb 25, 2014 2:25 pm

Just wow. That is so awesome Jules. One thing, how about adjusting it when you watch videos, I mean, to disable it. I am not a bash perfectionist.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: bbqshift

Unread post by machinebacon » Tue Feb 25, 2014 2:26 pm

start it again and press q - this resets it.
..gnutella..

User avatar
ivanovnegro
Minister of Truth
Posts: 5449
Joined: Wed Oct 17, 2012 11:12 pm

Re: bbqshift

Unread post by ivanovnegro » Tue Feb 25, 2014 2:31 pm

Ok, that sounds logical.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: bbqshift

Unread post by rhowaldt » Tue Feb 25, 2014 11:07 pm

that is cool! well done :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: bbqshift

Unread post by dkeg » Tue Feb 25, 2014 11:57 pm

I saw this before work today. Really great. I love the direction we've been posing going. Very creative, smart, and fuck you'ish.

Edit-stupid auto correct typo

Work hard; Complain less

User avatar
ChefIronBelly
Approved BBQer
Posts: 1044
Joined: Mon Jan 13, 2014 6:01 am
Location: Michigan

Re: bbqshift

Unread post by ChefIronBelly » Wed Feb 26, 2014 5:09 am

Just what my eyes need thanks.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: bbqshift

Unread post by GekkoP » Wed Feb 26, 2014 8:07 am

This will be useful, thanks!

User avatar
wei2912
runs Stable
Posts: 36
Joined: Wed Jun 18, 2014 7:59 pm
Location: Singapore

Re: bbqshift

Unread post by wei2912 » Mon Jun 23, 2014 5:58 pm

Seems like a case statement would be a better choice.

Great idea though, I never thought it could be done
GitHub || Blog

"Don't blindly believe what I say. Don't believe me because others convince you of my words. Don't believe anything you see, read, or hear from others, whether of authority, religious teachers or texts." - Buddha

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: bbqshift

Unread post by machinebacon » Mon Jun 23, 2014 6:27 pm

^ Originally I only wanted to shift red. Then I simply added the other colors. If you don't like it, please ignore :)
..gnutella..

User avatar
wei2912
runs Stable
Posts: 36
Joined: Wed Jun 18, 2014 7:59 pm
Location: Singapore

Re: bbqshift

Unread post by wei2912 » Tue Jun 24, 2014 8:23 am

I modified this script to have limits to the gamma passed to xrandr, so that we won't get unexpected behaviour.

Also did some refactoring.

Note that the limits are exclusive (that means if you set MIN to 0, you can't set the gamma to 0 or below, and likewise for MAX).

Code: Select all

#!/bin/bash
RR=1
GG=1
BB=1
LL=1

NR=1
NG=1
NB=1
NL=1

MIN=0 # min gamma
MAX=200 # max gamma

CON=`xrandr -q | grep con | cut -d " " -f 1 | xargs`
echo "Detected connectors are: $CON"
echo "Which do you want to manipulate?"
read MON

clear

set_val() {
  case $1 in
    RED)
      RR=$2
      NR=$(echo "$RR/100" | bc -l)
      ;;
    GREEN)
      GG=$2
      NG=$(echo "$GG/100" | bc -l)
      ;;
    BLUE)
      BB=$2
      NB=$(echo "$BB/100" | bc -l)
      ;;
    BRIGHTNESS)
      LL=$2
      NL=$(echo "$LL/100" | bc -l)
      ;;
  esac
}

inc_gamma() {
  let "VAL = $1 + 5"
  if (( "$VAL" < "$MAX" )); then
    set_val $2 $VAL
    echo "$2 increased to $VAL"
  else
    echo "$2 cannot be increased above or to $MAX."
  fi
}

dec_gamma() {
  let "VAL = $1 - 5"
  if (( "$VAL" > "$MIN" )); then
    set_val $2 $VAL
    echo "$2 decreased to $VAL"
  else
    echo "$2 cannot be decreased below or to $MIN."
  fi
}

echo "rR gG bB to move gamma"
echo "lL to adjust brightness"
echo "s to save, q to reset and quit."
while read -n1 -s; do
  case $REPLY in
    R) inc_gamma $RR "RED" ;;
    r) dec_gamma $RR "RED" ;;
    G) inc_gamma $GG "GREEN" ;;
    g) dec_gamma $GG "GREEN" ;;
    B) inc_gamma $BB "BLUE" ;;
    b) dec_gamma $BB "BLUE" ;;
    L) inc_gamma $LL "BRIGHTNESS" ;;
    l) dec_gamma $LL "BRIGHTNESS" ;;
    s|S)
      echo "xrandr --output $MON --gamma $NR:$NG:$NB --brightness $LL" > ~/xrandrconf
      chmod a+x ~/xrandrconf
      echo "Saved as ~/xrandrconf"
      exit 0
      ;;
    q|Q)
      xrandr --output $MON --gamma 1.0:1.0:1.0 --brightness 1.0
      exit 0
      ;;
  esac

  xrandr --output $MON --gamma $NR:$NG:$NB --brightness $NL > /dev/null 2>&1
done
If possible it'd be great if we could eliminate the conversion from integers to floats and instead directly modify these values as floats.
Last edited by wei2912 on Tue Jun 24, 2014 9:23 am, edited 1 time in total.
GitHub || Blog

"Don't blindly believe what I say. Don't believe me because others convince you of my words. Don't believe anything you see, read, or hear from others, whether of authority, religious teachers or texts." - Buddha

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: bbqshift

Unread post by rhowaldt » Tue Jun 24, 2014 9:16 am

^ cool, thanks :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

Post Reply