How to set up temperature on i3blocks?

Hello. I just installed EndeavourOS with i3wm a few hours ago and so far it’s working great! But I came across a little problem: I can’t get the temperature icon to show on the bar. I already customized it, changed a lot of stuff but this is the only thing I can’t do. I’ve been messing around with the i3blocks and i3status files for a while and nothing worked for me so far. Can someone help?

1 Like

Welcome aboard!

Which “temperature” are you referring to?

‘’[CPU-temperature]
label=
command=/home/jo/.config/i3/scripts/temperature
color=#96c6f8
interval=10’’
This. Is on the i3blocks.conf file. I tried to edit it and the i3status.conf to make it show up on the bar but it doesn’t.

Do you have Font Awesome installed?

1 Like

This was already done for you when you installed EndeavourOS. Restore the defaults?

command=~/home/jo/.config/i3/scripts/temperature

You are missing a ~

1 Like

if endeavour … blocks is ( ~/.config/i3/scripts/temperature ) that what on my old one… maybe it change ?

CPU-temperature]
label=CPU
command=~/.config/i3/scripts/temperature
color=#96c6f8
interval=10

1 Like

I installed font-awesome and changed the path but it still didn’t work

1 community/otf-font-awesome 5.15.1-1 (463.2 KiB 1.1 MiB) (Installed)
Is installed by default did you remove it? Also so all your other desired things in i3bar are working and just not cpu temp?

please return from terminal:
inxi -Fxxxza --no-host
sudo parted -l <—letter l not number 1

Yes, I had it installed by default and didn’t remove it. And yes, everything else I want is working.

Results from the terminal:
[jo@ThinkCentre-M58p ~]$ inxi -Fxxxza --no-host

System:
  Kernel: 5.9.11-arch2-1 x86_64 bits: 64 
  compiler: gcc v: 10.2.0 
  parameters: BOOT_IMAGE=/boot/vmlinuz-linux 
  root=UUID=431c03dd-b798-4e0c-baab-ef7583df7923 
  rw quiet 
  resume=UUID=483ef603-42a1-4e3d-bdde-452e1ca05ebe 
  loglevel=3 nowatchdog 
  Desktop: i3 4.19 info: i3bar 
  dm: LightDM 1.30.0 Distro: EndeavourOS 
Machine:
  Type: Desktop System: LENOVO 
  product: 6234F52 v: ThinkCentre M58p 
  serial: <filter> Chassis: type: 3 
  serial: <filter> 
  Mobo: LENOVO model: LENOVO serial: <filter> 
  BIOS: LENOVO v: 5CKT62AUS date: 05/24/2010 
CPU:
  Info: Dual Core model: Intel Core2 Duo E8400 
  bits: 64 type: MCP arch: Penryn family: 6 
  model-id: 17 (23) stepping: A (10) 
  microcode: A0B L2 cache: 6144 KiB 
  flags: lm nx pae sse sse2 sse3 sse4_1 ssse3 
  vmx 
  bogomips: 11974 
  Speed: 1995 MHz min/max: 2000/3000 MHz 
  Core speeds (MHz): 1: 2021 2: 2562 
  Vulnerabilities: Type: itlb_multihit 
  status: KVM: VMX disabled 
  Type: l1tf 
  mitigation: PTE Inversion; VMX: EPT disabled 
  Type: mds status: Vulnerable: Clear CPU 
  buffers attempted, no microcode; SMT 
  disabled 
  Type: meltdown mitigation: PTI 
  Type: spec_store_bypass status: Vulnerable 
  Type: spectre_v1 mitigation: usercopy/swapgs 
  barriers and __user pointer sanitization 
  Type: spectre_v2 mitigation: Full generic 
  retpoline, STIBP: disabled, RSB filling 
  Type: srbds status: Not affected 
  Type: tsx_async_abort status: Not affected 
Graphics:
  Device-1: Intel 4 Series Integrated Graphics 
  vendor: Lenovo ThinkCentre M6258 
  driver: i915 v: kernel bus ID: 00:02.0 
  chip ID: 8086:2e12 
  Display: x11 server: X.Org 1.20.9 
  driver: intel 
  unloaded: fbdev,modesetting,vesa 
  display ID: :0 screens: 1 
  Screen-1: 0 s-res: 1024x768 s-dpi: 96 
  s-size: 270x203mm (10.6x8.0") 
  s-diag: 338mm (13.3") 
  Monitor-1: VGA1 res: 1024x768 hz: 60 dpi: 87 
  size: 300x230mm (11.8x9.1") 
  diag: 378mm (14.9") 
  Message: Unable to show advanced data. 
  Required tool glxinfo missing. 
Audio:
  Device-1: Intel 82801JD/DO HD Audio 
  vendor: Lenovo driver: snd_hda_intel 
  v: kernel bus ID: 00:1b.0 chip ID: 8086:3a6e 
  Sound Server: ALSA v: k5.9.11-arch2-1 
Network:
  Device-1: Intel 82567LM-3 Gigabit Network 
  vendor: Lenovo driver: e1000e v: kernel 
  port: 1820 bus ID: 00:19.0 
  chip ID: 8086:10de 
  IF: enp0s25 state: down mac: <filter> 
  Device-2: Ralink MT7601U Wireless Adapter 
  type: USB driver: mt7601u bus ID: 1-2:2 
  chip ID: 148f:7601 
  IF: wlan0 state: up mac: <filter> 
Drives:
  Local Storage: total: 352.07 GiB 
  used: 6.89 GiB (2.0%) 
  SMART Message: Unable to run smartctl. Root 
  privileges required. 
  ID-1: /dev/sda vendor: Seagate 
  model: ST3250318AS size: 232.83 GiB 
  block size: physical: 512 B logical: 512 B 
  speed: 3.0 Gb/s rotation: 7200 rpm 
  serial: <filter> rev: CC49 scheme: MBR 
  ID-2: /dev/sdb vendor: Kingston 
  model: SNV425S2128GB size: 119.24 GiB 
  block size: physical: 512 B logical: 512 B 
  speed: 3.0 Gb/s serial: <filter> rev: 309a 
  scheme: MBR 
RAID:
  Hardware-1: Intel SATA Controller [RAID mode] driver: ahci v: 3.0 port: 1c00 
  bus ID: 00:1f.2 chip ID: 8086.2822 rev: 02 
Partition:
  ID-1: / raw size: 42.00 GiB 
  size: 41.09 GiB (97.84%) 
  used: 6.89 GiB (16.8%) fs: ext4 
  dev: /dev/sdb2 
Swap:
  Kernel: swappiness: 60 (default) 
  cache pressure: 100 (default) 
  ID-1: swap-1 type: partition size: 7.99 GiB 
  used: 0 KiB (0.0%) priority: -2 
  dev: /dev/sdb3 
Sensors:
  System Temperatures: cpu: 58.0 C mobo: N/A 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 155 Uptime: 16m wakeups: 0 
  Memory: 3.32 GiB used: 1002.3 MiB (29.5%) 
  Init: systemd v: 246 Compilers: gcc: 10.2.0 
  Packages: pacman: 753 lib: 193 Shell: Bash 
  v: 5.0.18 running in: sakura inxi: 3.1.09 

[jo@ThinkCentre-M58p ~]$ sudo parted -l
Modelo: ATA ST3250318AS (scsi)
Disco /dev/sda: 250GB
Tamanho do setor (lógico/físico): 512B/512B
Tabela de partições: msdos
Opções de disco: 

Número  Início  Fim    Tamanho  Tipo     Sistema de arquivos  Opções
 1      1049kB  250GB  250GB    primary  ntfs                 boot


Modelo: ATA KINGSTON SNV425S (scsi)
Disco /dev/sdb: 128GB
Tamanho do setor (lógico/físico): 512B/512B
Tabela de partições: msdos
Opções de disco: 

Número  Início  Fim     Tamanho  Tipo     Sistema de arquivos  Opções
 1      1049kB  74,3GB  74,3GB   primary  ntfs                 boot
 2      74,3GB  119GB   45,1GB   primary  ext4
 3      119GB   128GB   8584MB   primary  linux-swap(v1)

Please post the output with three ``` before and after the post or use the </> button. It is really hard to read otherwise.

Anyway if all you need is an icon, copy and paste from here: https://fontawesome.com/icons?d=gallery&q=temp
to your config.

it just icon missing? or no temp output

1 Like

Ok, I will.

No icon and no temp output.

what if you simple run the script in a terminal?

~/.config/i3/scripts/temperature

to see if the issue is with the script itself or some configs…

after your change … did you restart by mod+Shift+R

@joekamprad

that script need lm_sensors … right ?

I tried this and it didn’t work. The terminal says:

Cannot find temperature at /home/jo/.config/i3/scripts/temperature line 56.

can you show the script? my one do not have more then 35 line :wink:

(EDIT)
this is not the one used per default…

2 Likes

that new…

you can also try this one:

Summary
#!/bin/bash

TEMP_DEVICE="${BLOCK_INSTANCE:-Core}"
TEMP_OUTPUT=$(sensors | grep "${TEMP_DEVICE}")

IS_URGENT=0

TOTAL_TEMP=0
TOTAL_COUNT=0
while read RESULT_LINE; do
  TOTAL_COUNT=$((TOTAL_COUNT +1))
  CURRENT_TEMP=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '1p' | tr -d '+°C')
  URGENT_VALUE=$(echo "${RESULT_LINE}" | grep -o -E "[\+\-]?[0-9]*.[0-9]*°C" | sed -n '2p' | tr -d '+°C')

  TOTAL_TEMP=$(echo "scale=2;${TOTAL_TEMP}+${CURRENT_TEMP}" | bc -l)
  IS_CRITICAL=$(echo "scale=0;${CURRENT_TEMP}-${URGENT_VALUE} >= 0" | bc -l)

  if [[ "${IS_CRITICAL}" -eq 1 ]]; then
    IS_URGENT=1
  fi
done <<< "$(echo -e "$TEMP_OUTPUT")"

AVERAGE_TEMP=$(echo "scale=0;${TOTAL_TEMP}/${TOTAL_COUNT}" | bc -l)

if [[ "${TOTAL_COUNT}" -gt 1 ]]; then
  AVERAGE_TEMP=" ${AVERAGE_TEMP}"
fi

echo "${AVERAGE_TEMP}°C"
#echo "${AVERAGE_TEMP}°C"
#echo ""

if [[ "${IS_URGENT}" -eq 1 ]]; then
  exit 33
fi
1 Like

That’s my script:

#!/usr/bin/env perl
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Copyright 2014 Andreas Guldstrand <andreas.guldstrand@gmail.com>
# Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use warnings;
use utf8;
use Getopt::Long;

binmode(STDOUT, ":utf8");

# default values
my $t_warn = $ENV{T_WARN} || 70;
my $t_crit = $ENV{T_CRIT} || 90;
my $chip = $ENV{SENSOR_CHIP} || "";
my $temperature = -9999;

sub help {
    print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n";
    print "-w <percent>: warning threshold to become yellow\n";
    print "-c <percent>: critical threshold to become red\n";
    print "--chip <chip>: sensor chip\n";
    exit 0;
}

GetOptions("help|h" => \&help,
           "w=i"    => \$t_warn,
           "c=i"    => \$t_crit,
           "chip=s" => \$chip);

# Get chip temperature
open (SENSORS, "sensors -u $chip |") or die;
while (<SENSORS>) {
    if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) {
        $temperature = $1;
        last;
    }
}
close(SENSORS);

$temperature eq -9999 and die 'Cannot find temperature';

# Print short_text, full_text
print "$temperature°C\n" x2;

# Print color, if needed
if ($temperature >= $t_crit) {
    print "#FF0000\n";
    exit 33;
} elsif ($temperature >= $t_warn) {
    print "#FFFC00\n";
}

exit 0;