Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-09-30 01:39:32

forest_essential
Member
Registered: 2023-03-04
Posts: 5
Windows 10Firefox 115.0

here is my script for adjusting screen temp as the time changes.

What are some of your scripts or reasons for doing scripts?
e, the values im adjusting still.  probably the day time values will be adjusted to be cooler.

#!/bin/bash
# Check if xsct is installed
if ! command -v xsct &> /dev/null
then
    echo "Error: xsct not found."
    exit 1
fi

# Retrieve the current hour (0-23) and adjust the temperature accordingly
current_hour=$(date +%H)
current_min=$(date +%M)

while true; do

new_temperature=4000

if (( $current_hour < 12 )); then
if (( $current_min < 14)); then
    new_temperature=6500
elif (( $current_min < 29)); then
    new_temperature=6400
elif (( $current_min < 44)); then
    new_temperature=6300
elif (( $current_min < 59)); then
    new_temperature=6100
fi
elif (( $current_hour < 13 )); then
if (( $current_min < 14)); then
    new_temperature=6000
elif (( $current_min < 29)); then
    new_temperature=5900
elif (( $current_min < 44)); then
    new_temperature=5900
elif (( $current_min < 59)); then
    new_temperature=5900
fi
elif (( $current_hour < 14 )); then
if (( $current_min < 14)); then
    new_temperature=5800
elif (( $current_min < 29)); then
    new_temperature=5800
elif (( $current_min < 44)); then
    new_temperature=5750
elif (( $current_min < 59)); then
    new_temperature=5750
fi
elif (( $current_hour < 15 )); then
if (( $current_min < 14)); then
    new_temperature=5650
elif (( $current_min < 29)); then
    new_temperature=5600
elif (( $current_min < 44)); then
    new_temperature=5600
elif (( $current_min < 59)); then
    new_temperature=5500
fi
elif (( $current_hour < 16 )); then
if (( $current_min < 14)); then
    new_temperature=4800
elif (( $current_min < 29)); then
    new_temperature=4700
elif (( $current_min < 44)); then
    new_temperature=4600
elif (( $current_min < 59)); then
    new_temperature=4500
fi
elif (( $current_hour < 17 )); then
if (( $current_min < 14)); then
    new_temperature=4400
elif (( $current_min < 29)); then
    new_temperature=4300
elif (( $current_min < 44)); then
    new_temperature=4200
elif (( $current_min < 59)); then
    new_temperature=4100
fi
elif (( $current_hour < 18 )); then
if (( $current_min < 14)); then
    new_temperature=4000
elif (( $current_min < 29)); then
    new_temperature=3900
elif (( $current_min < 44)); then
    new_temperature=3800
elif (( $current_min < 59)); then
    new_temperature=3700
fi
elif (( $current_hour < 19 )); then
if (( $current_min < 14)); then
    new_temperature=3600
elif (( $current_min < 29)); then
    new_temperature=3500
elif (( $current_min < 44)); then
    new_temperature=3500
elif (( $current_min < 59)); then
    new_temperature=3350
fi
elif (( $current_hour < 20 )); then
if (( $current_min < 14)); then
    new_temperature=3200
elif (( $current_min < 29)); then
    new_temperature=3100
elif (( $current_min < 44)); then
    new_temperature=3050
elif (( $current_min < 59)); then
    new_temperature=3000
fi
elif (( $current_hour < 21 )); then
if (( $current_min < 14)); then
    new_temperature=2900
elif (( $current_min < 29)); then
    new_temperature=2800
elif (( $current_min < 44)); then
    new_temperature=2700
elif (( $current_min < 59)); then
    new_temperature=2650
fi
elif (( $current_hour < 22 )); then
if (( $current_min < 14)); then
    new_temperature=2500
elif (( $current_min < 29)); then
    new_temperature=2300
elif (( $current_min < 44)); then
    new_temperature=2200
elif (( $current_min < 59)); then
    new_temperature=2100
fi
elif (( $current_hour < 23 )); then
if (( $current_min < 14)); then
    new_temperature=2000
elif (( $current_min < 29)); then
    new_temperature=1900
elif (( $current_min < 44)); then
    new_temperature=1850
elif (( $current_min < 59)); then
    new_temperature=1800
fi
elif (( $current_hour < 24 )); then
if (( $current_min < 14)); then
    new_temperature=1700
elif (( $current_min < 29)); then
    new_temperature=1600
elif (( $current_min < 44)); then
    new_temperature=1550
elif (( $current_min < 59)); then
    new_temperature=1400
fi
elif (( $current_hour = 24 )); then
    new_temperature=1350

fi
# Call xsct to adjust the screen temperature
echo "Adjusting screen temperature to $new_temperature K."
xsct $new_temperature
sleep 150
done

Added later 10 h 47 min 04 s:
there is an edit to under the line "if (( $current_hour < 12 )); then"

it should have a line that says "new_temperature=6500"

Last edited by forest_essential (2024-09-30 01:40:41)

Offline

#2 2024-10-10 15:27:32

lvsl
Member
Registered: 2024-08-22
Posts: 2
LinuxChrome 129.0

Re: here is my script for adjusting screen temp as the time changes.

tongue So I'm not the only one who write scripts to solve daily stuff. When I installed linux I had to deal with a really headache problem that hurts my eyes when I stare at my screen and I made a temp fix. But now since I put the script as part of a startup program I run every time I logon xfce, now it does the job for me.

For all the adjustments, I used my phone white screen as a reference, searched for a color picker, and then picked a color that looks as white/gray as my phone screen, and then calculated the percentage of rgb values I had to reduce to get the desire "white" I wanted my screen to me, later added the loss contrast back resulting on the first xcalib command. Now the temp fix turned permanent but later I might use a more proper method. The fix took me around 2 hours to make. At least it stopped my eyes from bleeding  hmm

xcalib -green 0.6 0.0 90.0 -red 0.6 0.0 92.0 -blue 0.6 0.0 99.0 -alter
xcalib -gc 1.5 -a

echo "Monitor adjusted. To reset enter xcalib -c"

Another one specifically for Arch linux that got me adding a lot more code than I imagine. Because the invert screen script (xcalib -i -a) undid itself once I used xrandr. The only minor problem is it retains the previous invert/not-invert status and might invert the screen even I did not tell it to. But it's easily fixed with a cntl-alt-i, which is my invert script

#!/bin/bash

# ###############################################################
# Script to adjust brightness of the monitor
# Note1: This script is designed as a workaround for arch linux's
#        weirdness
# Note2: Make the file ~/isinvert for the script to action
# ###############################################################

# -- exit if brightness is too bright or dim --

# value is given in decimal form but only integer comparasion is available
brightnessValue=$(echo "scale=0;$1*100/1" | bc)

if [ $brightnessValue -gt 111 ]; then
    echo 'Value not set: Too large. Might whiten the screen'
    exit 1
elif [ $brightnessValue -lt 14 ]; then
    echo 'Value not set: Too small. Will dim the screen too much. '
    exit 1
fi

# -- reset xcalib and adjust brightness --
xcalib -c &> /dev/null
xrandr --output eDP-1 --brightness ${1} &> /dev/null
~/Desktop/adjust-xcalib.sh &> /dev/null

# -- script for restoring screen if it's inverted --
isinvert=$(cat ~/isinvert)

if [ $isinvert = 'true' ]; then
    xcalib -i -a &> /dev/null # re-invert the screen after its resetted
else
    echo 'screen not inverted beforehand so nothing is done in here' > /dev/null
fi

Edit: forgot the invert script

#!/bin/bash

# -- script to invert display and also save it to a file --

isinvert=$(cat /home/js/isinvert)
echo 'isinvert='$isinvert

xcalib -i -a
if [ $isinvert = 'false' ]; then
    echo 'true' > /home/js/isinvert
else
    echo 'false' > /home/js/isinvert
fi

Last edited by lvsl (2024-10-10 16:05:18)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.007 seconds, 7 queries executed - Memory usage: 547.27 KiB (Peak: 547.89 KiB) ]