How Does Konsole "Magically" Show Me Colors?  [Solved]

Help with the version of MX KDE officially released by the Development Team.
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
operadude
Posts: 1055
Joined: Tue Nov 05, 2019 12:08 am

How Does Konsole "Magically" Show Me Colors?

#1 Post by operadude »

Curious as to how KDE's "Konsole" (Terminal Emulator) can show me colors when I hover over the names of colors that I have defined with the appropriate RGB codes.

I don't get this functionality in Xfce's, nor in Fluxbox's, Terminal Emulator (using the defaults).

Just a curiosity...and...it's pretty cool :exclamation:

I will upload the python3 code that I have implemented in Geany, with some output screenshots.

First, QSI:

Code: Select all

Snapshot created on: 20240404_1501
System:
  Kernel: 6.1.0-10-amd64 [6.1.38-2] arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1.0-10-amd64 root=UUID=<filter> ro quiet splash
  Desktop: KDE Plasma v: 5.27.5 info: plank wm: kwin_x11 vt: 7 dm: SDDM Distro: MX-23.2_x64
    Libretto October 13 2023 base: Debian GNU/Linux 12 (bookworm)
Machine:
  Type: Desktop System: Gigabyte product: H270-HD3 v: N/A serial: <superuser required>
  Mobo: Gigabyte model: H270-HD3-CF v: x.x serial: <superuser required> UEFI: American Megatrends
    v: F5 date: 04/24/2017
Battery:
  Device-1: hidpp_battery_0 model: Logitech Wireless Mouse PID:0080 serial: N/A
    charge: 55% (should be ignored) rechargeable: yes status: discharging
CPU:
  Info: model: Intel Core i3-7100 bits: 64 type: MT MCP arch: Kaby Lake gen: core 7 level: v3
    note: check built: 2018 process: Intel 14nm family: 6 model-id: 0x9E (158) stepping: 9
    microcode: 0xF4
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 3 MiB desc: 1x3 MiB
  Speed (MHz): avg: 800 min/max: 800/3900 scaling: driver: intel_pstate governor: powersave
    cores: 1: 800 2: 800 3: 800 4: 800 bogomips: 31199
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: retbleed mitigation: IBRS
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: IBRS, IBPB: conditional, STIBP: conditional, RSB filling,
    PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Oland PRO [Radeon R7 240/340 / Radeon 520] vendor: Micro-Star MSI driver: radeon
    v: kernel alternate: amdgpu arch: GCN-1 code: Southern Islands process: TSMC 28nm built: 2011-20
    pcie: gen: 3 speed: 8 GT/s lanes: 8 ports: active: HDMI-A-1 empty: DVI-D-1,VGA-1
    bus-ID: 01:00.0 chip-ID: 1002:6613 class-ID: 0300 temp: 42.0 C
  Display: x11 server: X.Org v: 1.21.1.7 with: Xwayland v: 22.1.9 compositor: kwin_x11 driver: X:
    loaded: radeon unloaded: fbdev,modesetting,vesa dri: radeonsi gpu: radeon display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22") s-diag: 582mm (22.93")
  Monitor-1: HDMI-A-1 mapped: HDMI-0 model: Samsung built: 2007 res: 1920x1080 hz: 60 dpi: 305
    gamma: 1.2 size: 160x90mm (6.3x3.54") diag: 184mm (7.2") ratio: 16:9 modes: max: 1920x1080
    min: 640x480
  API: OpenGL v: 4.5 Mesa 22.3.6 renderer: OLAND ( LLVM 15.0.6 DRM 2.50 6.1.0-10-amd64)
    direct-render: Yes
Audio:
  Device-1: Intel 200 Series PCH HD Audio vendor: Gigabyte driver: snd_hda_intel v: kernel
    bus-ID: 00:1f.3 chip-ID: 8086:a2f0 class-ID: 0403
  Device-2: AMD Oland/Hainan/Cape Verde/Pitcairn HDMI Audio [Radeon HD 7000 Series]
    vendor: Micro-Star MSI driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 8
    bus-ID: 01:00.1 chip-ID: 1002:aab0 class-ID: 0403
  API: ALSA v: k6.1.0-10-amd64 status: kernel-api tools: alsamixer,amixer
  Server-1: PipeWire v: 1.0.0 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 Ethernet I219-V vendor: Gigabyte driver: e1000e v: kernel port: N/A
    bus-ID: 00:1f.6 chip-ID: 8086:15b8 class-ID: 0200
  IF: eth0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  IF-ID-1: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A
Drives:
  Local Storage: total: 7.8 TiB used: 5.54 TiB (71.0%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 970 EVO 250GB size: 232.89 GiB
    block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
    rev: 1B2QEXE7 temp: 32.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 model: SATA SSD size: 111.79 GiB block-size: physical: 512 B
    logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: 61.3 scheme: GPT
  ID-3: /dev/sdb maj-min: 8:16 vendor: Kingston model: SA400S37120G size: 111.79 GiB block-size:
    physical: 512 B logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: 61K1 scheme: MBR
  ID-4: /dev/sdc maj-min: 8:32 vendor: Seagate model: ST3000DM001-1ER166 size: 2.73 TiB
    block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter>
    rev: CC25 scheme: GPT
  ID-5: /dev/sdd maj-min: 8:48 vendor: Toshiba model: DT01ACA050 size: 465.76 GiB block-size:
    physical: 4096 B logical: 512 B speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter> rev: A750
    scheme: GPT
  ID-6: /dev/sde maj-min: 8:64 vendor: Western Digital model: WD5000AADS-00S9B0 size: 465.76 GiB
    block-size: physical: 512 B logical: 512 B speed: 3.0 Gb/s type: N/A serial: <filter> rev: 0A01
    scheme: GPT
  ID-7: /dev/sdf maj-min: 8:80 type: USB vendor: Seagate model: Expansion Desk size: 3.64 TiB
    block-size: physical: 4096 B logical: 4096 B type: N/A serial: <filter> rev: 0739 scheme: MBR
  ID-8: /dev/sdk maj-min: 8:160 type: USB vendor: Generic model: STORAGE DEVICE size: 14.57 GiB
    block-size: physical: 512 B logical: 512 B type: N/A serial: <filter> rev: 1203 scheme: GPT
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  ID-9: /dev/sdl maj-min: 8:176 type: USB model: Storage Device size: 7.42 GiB block-size:
    physical: 512 B logical: 512 B type: N/A serial: N/A rev: 1.00 scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  ID-10: /dev/sdm maj-min: 8:192 type: USB model: Storage Device size: 14.84 GiB block-size:
    physical: 512 B logical: 512 B type: N/A serial: N/A rev: 1.00 scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  ID-11: /dev/sdn maj-min: 8:208 type: USB model: Storage Device size: 3.69 GiB block-size:
    physical: 512 B logical: 512 B type: N/A serial: N/A rev: 1.00 scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  ID-12: /dev/sdo maj-min: 8:224 type: USB model: Storage Device size: 7.4 GiB block-size:
    physical: 512 B logical: 512 B type: N/A serial: N/A rev: 1.00 scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
  ID-13: /dev/sdp maj-min: 8:240 type: USB model: Mass Storage Device size: 29.72 GiB block-size:
    physical: 512 B logical: 512 B type: N/A serial: <filter> rev: 1.00 scheme: MBR
  SMART Message: Unknown USB bridge. Flash drive/Unsupported enclosure?
Partition:
  ID-1: / raw-size: 25 GiB size: 24.44 GiB (97.76%) used: 11.08 GiB (45.4%) fs: ext4
    dev: /dev/nvme0n1p4 maj-min: 259:4
  ID-2: /boot/efi raw-size: 256 MiB size: 252 MiB (98.46%) used: 1.6 MiB (0.7%) fs: vfat
    dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 25 GiB size: 24.44 GiB (97.76%) used: 10.07 GiB (41.2%) fs: ext4
    dev: /dev/nvme0n1p5 maj-min: 259:5
Swap:
  Kernel: swappiness: 15 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: partition size: 32 GiB used: 512 KiB (0.0%) priority: -2
    dev: /dev/nvme0n1p10 maj-min: 259:10
Sensors:
  System Temperatures: cpu: 40.0 C mobo: N/A gpu: radeon temp: 41.0 C
  Fan Speeds (RPM): N/A
Repos:
  Packages: pm: dpkg pkgs: 2694 libs: 1429 tools: apt,apt-get,aptitude,nala pm: rpm pkgs: 0
    pm: flatpak pkgs: 0
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/debian-stable-updates.list
    1: deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/debian.list
    1: deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    2: deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/mx.list
    1: deb http://mxrepo.com/mx/repo/ bookworm main non-free
  Active apt repos in: /etc/apt/sources.list.d/skype-stable.list
    1: deb [arch=amd64] https://repo.skype.com/deb stable main
Info:
  Processes: 292 Uptime: 6h 52m wakeups: 6 Memory: 31.3 GiB used: 3.73 GiB (11.9%) Init: SysVinit
  v: 3.06 runlevel: 5 default: graphical tool: systemctl Compilers: gcc: 12.2.0 alt: 12
  Client: shell wrapper v: 5.2.15-release inxi: 3.3.26
Boot Mode: UEFI
Python3 code (from Geany):

Code: Select all

from collections import namedtuple


def main():
	
	# Create a Named Tuple Object:
	Color = namedtuple('Color', ['color', 'value'])
	
	# Instantiate Our Specific Named Tuple Objects
	primary_colors = [
		Color(color='WHITE', value=(red:=255, green:=255, blue:=255)),
		Color(color='RED', value=(red:=255, green:=0, blue:=0)),
		Color(color='GREEN', value=(red:=0, green:=255, blue:=0)),
		Color(color='BLUE', value=(red:=0, green:=0, blue:=255))
	]
	
	# Print the Values of the Colors as Named Tuples:
	print('Be sure to hover over the color name, e.g. "red"')
	print('Doing so will show you the actual colors!!!', '\n', '\n')
	print('Primary Colors, as represented by our Named Tuple Objects,')
	print('Using RGB (Red-Green-Blue) Decimal Codes:', '\n')

	for color in primary_colors:
		print(f'{color.color}:\t{color.value}')
	print(); print()
	
	# Print the Named Tuples as a Dictionary:
	print('Primary Color Named Tuple Objects as a Dictionary:', '\n')
	
	for color in primary_colors:
		print(f'{color._asdict()}')
	
		
if __name__ == "__main__":
	main()
And now, images from running the python3 script, and hovering-over the names of the colors:
The first image is just the output, without hovering over the names of the colors:

Image

Image

Image

Image

Image

Seeking Enlightenment :cool:

User avatar
operadude
Posts: 1055
Joined: Tue Nov 05, 2019 12:08 am

Re: How Does Konsole "Magically" Show Me Colors?

#2 Post by operadude »

Now trying on Fluxbox, with Xfce4-terminal (default):

Here's what I get when hovering over the names of the colors ("WHITE" and "RED").
The first pic is just showing which terminal emulator Geany is defaulting to on my Fluxbox:


Image

Image

Image

No point in adding more of the same.

When hovering over the names of the colors, I DO NOT get pop-ups of the actual colors.

Any clue why KDE's "Konsole" does show the colors?

Again, I like the functionality of KDE's "Konsole"; just curious as to how this works :exclamation:

User avatar
operadude
Posts: 1055
Joined: Tue Nov 05, 2019 12:08 am

Re: How Does Konsole "Magically" Show Me Colors?

#3 Post by operadude »

On the right path!

Found this:

https://www.reddit.com/r/kde/comments/ ... color_in/

With the following explanation (lower down the page):

Code: Select all

mikaleowiii 3y ago
Found about it some time ago, but as my editor (neovim) already has some color displayer that better suits me, i'm looking to disable that feature
Do someone know how ?

draeath 1y ago
So, in case this comes up for someone else.
    Settings -> Edit Current Profile (if you're using default, you need to make a new one first
    Go to the Mouse section, then the Miscellaneous tab. Find and uncheck "Preview Colors on hover"
But, this doesn't answer how it all works under the hood (which was my real question).

Will keep investigating, and report back :exclamation:

:crossfingers:

User avatar
dolphin_oracle
Developer
Posts: 22700
Joined: Sun Dec 16, 2007 12:17 pm

Re: How Does Konsole "Magically" Show Me Colors?  [Solved]

#4 Post by dolphin_oracle »

I'm gonna presume that the konsole developer decided he wanted to display colors and built it in, so its internal to the konsole code. many terminals have tricks for different things.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

User avatar
operadude
Posts: 1055
Joined: Tue Nov 05, 2019 12:08 am

Re: How Does Konsole "Magically" Show Me Colors?

#5 Post by operadude »

D.O. to the Rescue :exclamation:
dolphin_oracle wrote: Fri Apr 26, 2024 8:18 am I'm gonna presume that the konsole developer decided he wanted to display colors and built it in, so its internal to the konsole code. many terminals have tricks for different things.
:number1:

So, will need to dig into the guts of Konsole if I want to go further down the Rabbit Hole :exclamation:

:p

Post Reply

Return to “MX KDE Official Release”