How to use wlsunset/light.sh?

I want to edit the light.sh script in ~/.config/sway/scripts. i want to add my cordinates so it will be 4000k at night. i’m not sure what they are currently, but it’s brighter than 4000k. i assume that is because it’s not using my coordinates?

i have searched online, read through arch wiki, looked at google and github. i also read the page you posted below, before and after it was posted. i don’t see it mentioned anywhere how to use wlsunset besides manually, which i can do but want to do it automatically. i think that is why y’all used a script, and why i want to edit it. although i am not sure if that is the best way to go about it.

i see 4xx client error but i’m not sure what i need to do to not have 4xx client error. should i try and understand how to script first? and i tried to provide the 412 preconditions. i can add more or do more if it is needed, i’m not sure what i should do next though.

i’m sorry i broke the rules.

System:
  Kernel: 6.7.5-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
    clocksource: tsc avail: hpet,acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=f0ee726f-b78c-4fed-b27f-2bb9de98ea04 rw rootflags=subvol=@
    quiet loglevel=3 ibt=off
  Desktop: Sway v: 1.8.1 with: waybar tools: swayidle avail: swaylock vt: 1
    lm: greetd Distro: Garuda base: Arch Linux
Machine:
  Type: Desktop Mobo: Gigabyte model: Z590 AORUS ELITE AX v: x.x
    serial: <superuser required> uuid: <superuser required> UEFI: American
    Megatrends LLC. v: F3 date: 01/20/2021
CPU:
  Info: model: Intel Core i7-10700K bits: 64 type: MT MCP arch: Comet Lake
    gen: core 10 level: v3 note: check built: 2020 process: Intel 14nm family: 6
    model-id: 0xA5 (165) stepping: 5 microcode: 0xF8
  Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled cache:
    L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 2 MiB desc: 8x256 KiB
    L3: 16 MiB desc: 1x16 MiB
  Speed (MHz): avg: 800 min/max: 800/5100 scaling: driver: intel_pstate
    governor: powersave cores: 1: 800 2: 800 3: 800 4: 800 5: 800 6: 800 7: 800
    8: 800 9: 800 10: 800 11: 800 12: 800 13: 800 14: 800 15: 800 16: 800
    bogomips: 121596
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities: <filter>
Graphics:
  Device-1: AMD Navi 23 [Radeon RX 6650 XT / 6700S 6800S] vendor: Sapphire
    driver: amdgpu v: kernel arch: RDNA-2 code: Navi-2x process: TSMC n7 (7nm)
    built: 2020-22 pcie: gen: 4 speed: 16 GT/s lanes: 16 ports:
    active: HDMI-A-1 empty: DP-1,DP-2,DP-3 bus-ID: 03:00.0 chip-ID: 1002:73ef
    class-ID: 0300
  Display: wayland server: Xwayland v: 23.2.4 compositor: Sway v: 1.8.1
    driver: gpu: amdgpu display-ID: 1
  Monitor-1: HDMI-A-1 model: 27E1QA serial: <filter> built: 2022
    res: 2560x1440 hz: 60 dpi: 108 gamma: 1.2 scale: 1
    size: 597x336mm (23.5x13.23") diag: 685mm (27") ratio: 16:9 modes:
    max: 2560x1440 min: 720x400
  API: Vulkan v: 1.3.276 layers: 7 device: 0 type: discrete-gpu name: AMD
    Radeon RX 6650 XT (RADV NAVI23) driver: mesa radv v: 24.0.1-arch1.1
    device-ID: 1002:73ef surfaces: xcb,xlib,wayland device: 1 type: cpu
    name: llvmpipe (LLVM 16.0.6 256 bits) driver: mesa llvmpipe
    v: 24.0.1-arch1.1 (LLVM 16.0.6) device-ID: 10005:0000
    surfaces: xcb,xlib,wayland
  API: EGL Message: EGL data requires eglinfo. Check --recommends.
Audio:
  Device-1: Intel vendor: Gigabyte driver: snd_hda_intel v: kernel
    bus-ID: 00:1f.3 chip-ID: 8086:f0c8 class-ID: 0403
  Device-2: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel v: kernel
    pcie: gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 03:00.1 chip-ID: 1002:ab28
    class-ID: 0403
  Device-3: FDUCE PRO AUDIO MADE driver: snd-usb-audio type: USB rev: 1.1
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-5:3 chip-ID: 8888:1234
    class-ID: 0300 serial: <filter>
  API: ALSA v: k6.7.5-zen1-1-zen status: kernel-api tools: N/A
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: PipeWire v: 1.0.3 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel Tiger Lake PCH CNVi WiFi driver: iwlwifi v: kernel
    bus-ID: 00:14.3 chip-ID: 8086:43f0 class-ID: 0280
  IF: wlo1 state: down mac: <filter>
  Device-2: Realtek RTL8125 2.5GbE vendor: Gigabyte driver: r8169 v: kernel
    pcie: gen: 2 speed: 5 GT/s lanes: 1 port: 3000 bus-ID: 05:00.0
    chip-ID: 10ec:8125 class-ID: 0200
  IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  Info: services: NetworkManager, systemd-timesyncd, wpa_supplicant
Bluetooth:
  Device-1: Intel AX201 Bluetooth driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-14:10 chip-ID: 8087:0026
    class-ID: e001
  Report: btmgmt ID: hci0 rfk-id: 1 state: up address: <filter> bt-v: 5.2
    lmp-v: 11 status: discoverable: no pairing: no class-ID: 6c0104
Drives:
  Local Storage: total: 3.64 TiB used: 185.23 GiB (5.0%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 870 EVO 2TB
    size: 1.82 TiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 2B6Q scheme: GPT
  ID-2: /dev/sdb maj-min: 8:16 vendor: Samsung model: SSD 870 EVO 2TB
    size: 1.82 TiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 2B6Q scheme: GPT
  ID-3: /dev/sdc maj-min: 8:32 vendor: Kingston model: DataTraveler G3
    size: 3.66 GiB block-size: physical: 512 B logical: 512 B type: USB rev: 2.0
    spd: 480 Mb/s lanes: 1 mode: 2.0 tech: N/A serial: <filter> fw-rev: PMAP
    scheme: MBR
Partition:
  ID-1: / raw-size: 1.82 TiB size: 1.82 TiB (100.00%) used: 185.23 GiB (9.9%)
    fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 584 KiB (0.2%) fs: vfat dev: /dev/sda1 maj-min: 8:1
  ID-3: /home raw-size: 1.82 TiB size: 1.82 TiB (100.00%)
    used: 185.23 GiB (9.9%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-4: /var/log raw-size: 1.82 TiB size: 1.82 TiB (100.00%)
    used: 185.23 GiB (9.9%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-5: /var/tmp raw-size: 1.82 TiB size: 1.82 TiB (100.00%)
    used: 185.23 GiB (9.9%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
  ID-1: swap-1 type: zram size: 31.21 GiB used: 0 KiB (0.0%) priority: 100
    comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 16 dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 33.0 C mobo: 25.0 C gpu: amdgpu temp: 32.0 C
    mem: 30.0 C
  Fan Speeds (rpm): N/A gpu: amdgpu fan: 0
Info:
  Memory: total: 32 GiB available: 31.21 GiB used: 3.43 GiB (11.0%)
  Processes: 404 Power: uptime: 15m states: freeze,mem,disk suspend: deep
    avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
    suspend, test_resume image: 12.47 GiB Init: systemd v: 255
    default: graphical tool: systemctl
  Packages: pm: pacman pkgs: 1408 libs: 458 tools: paru Compilers:
    gcc: 13.2.1 Shell: garuda-inxi default: Bash v: 5.2.26
    running-in: terminator inxi: 3.3.33
Garuda (2.6.23-1):
  System install date:     2024-02-11
  Last full system update: 2024-02-22
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       Probably (Run as root to verify)
  Failed units:
1 Like

I’m not sure what you mean by 4000k, but there is no need to add your coordinates to the script because the whole point of the script is to determine your latitude and longitude for you, based on the output of curl -s http://ip-api.com/json.

#!/bin/sh
CONTENT=$(curl -s http://ip-api.com/json/)
longitude=$(echo $CONTENT | jq .lon)
latitude=$(echo $CONTENT | jq .lat)
wlsunset -l $latitude -L $longitude

I tested this script just now and it definitely works.

If you want to manually enter your latitude and longitude instead of using the script, then you should edit the line in ~/.config/sway/config.d/autostart_applications that calls the script, to instead use your custom wlsunset command. Putting it in ~/.config/sway/config.d/autostart_applications is what gets it running automatically.

Change this line:

exec ~/.config/sway/scripts/light.sh

To something like this:

exec wlsunset -l 39.9 -L 116.3

Substitute 39.9 for your latitude, and 116.3 for your longitude.

You can see other supported options with wlsunset -h:

❯ wlsunset -h
usage: wlsunset [options]
  -h             show this help message
  -v             show the version number
  -o <output>    name of output (display) to use,
                 by default all outputs are used
                 can be specified multiple times
  -t <temp>      set low temperature (default: 4000)
  -T <temp>      set high temperature (default: 6500)
  -l <lat>       set latitude (e.g. 39.9)
  -L <long>      set longitude (e.g. 116.3)
  -S <sunrise>   set manual sunrise (e.g. 06:30)
  -s <sunset>    set manual sunset (e.g. 18:30)
  -d <duration>  set manual duration in seconds (e.g. 1800)
  -g <gamma>     set gamma (default: 1.0)
2 Likes

i’m not sure what the issue was, i don’t think it was working for me. my screen wouldn’t turn orange. i think i checked and even killed wlsunset and light.sh. to check and see, it was the same.

thanks anyway! yes i ended up finding a similar solution. i’m not sure if this is proper, i was confused because i thought wlsunset would have a config like redshift. i don’t think that is the case though. i’ve just never run accross that type of program before.

but, i just ended up adding

exec ‘wlsunset -l x -L y’ to /home/user/.config/sway/config

from this reference/autostart.

https://wiki.archlinux.org/title/I3

i’m now using an orange screen and am happy.

thanks.

Experiencing quite the same anomalies with two monitor set. It is randomly choose monitors to apply light settings. Sometime one, sometime another and sometime both of them. So I gave up and just make shortcut for the ‘idle_inhibitor’ in waybar. When I make right-clicking and it re-initiate(restarts) light script. Like this below:

        "idle_inhibitor": {
            "format": "{icon}",
            "format-icons": {
                "activated": "",
                "deactivated": ""
            },
            "on-click-right": "~/.config/sway/scripts/light.sh"
        },
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.