Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linux only: random dark modes for KDE
#1
Lightbulb 
This is a program that fabricates desktop environment color sets for KDE Plasma. :O

It creates a definition which changes the colors for the window title bar and stuff contained inside the window such as buttons and text fields. It also affects the "main" panel that contains the desktop menu, digital clock, notifications etc.

The random scheme could be improved. Especially for the window title bar. Generally dark has to contrast with light. It seems far too often it creates bright pink as foreground color, but the important thing is that it could be seen. The color settings for the tooltip are not touched. The original definition was from "Oxygen Cold".

This program creates only "dark" modes. To get light ones might have to tone down what two of the functions do. Swap "lightcolor$" and "darkcolor$" assignments on RHS for starters. But something has to be done also about "twincolor$" so it returns dark colors, ie. the value is related to "darkcolor$".

The color definitions are dropped right into the area the System Settings/Appearance/Colors expects them so they could be viewed straight away. Otherwise it's clunky to load one definition at a time from disk only to see what it is. After all, they are harmless text files. (Um, for some people being unable to see anything on the screen clearly, because foreground and background colors are almost the same, counts as "causing harm" but anyway. Windows doesn't allow it, but also doesn't allow too many other combinations which could be sensible but could tire the eyes faster.)

The output example of this program will not change the position nor behavior of widgets or other screen elements, or any aspect of its appearance than the colors. This doesn't affect applications such as Kate and Konsole which have distinct settings, even if they were written by KDE. (Kate/KWrite does have a plethora of color settings and a program like this one could be created for it.) It might cause some "Plasmoids" and other widgets to look weird, and it might not work well with certain visual effects the young people love so well. It won't affect a bunch of other applications that keep their own settings such as Geany.

Code: (Select All)
'by mnrvovrfc 9-May-2023
'for Linux, and KDE Plasma v5.20 and later
$CONSOLE:ONLY
option _explicit
dim sco(1 to 12) as string
dim ani$, a$, lf$, u as long, ff as long
dim as integer rr, gg, bb, i, w

lf$ = chr$(10)

for w = 1 to 10

for i = 1 to 3
    sco(i) = lightcolor$
    sco(i + 5) = darkcolor$
next
sco(4) = sco(Random1(3))
sco(5) = sco(Random1(3))
sco(9) = sco(Random1(3) + 5)
sco(10) = sco(Random1(3) + 5)
a$ = twincolor$
u = instr(a$, "|")
sco(11) = left$(a$, u - 1)
sco(12) = mid$(a$, u + 1)

ani$ = "[ColorEffects:Disabled]" + lf$ +_
"ColorAmount=0" + lf$ +_
"ColorEffect=0" + lf$ +_
"ContrastAmount=0.65" + lf$ +_
"ContrastEffect=1" + lf$ +_
"IntensityAmount=0.1" + lf$ +_
"IntensityEffect=2" + lf$ +_
"" + lf$ +_
"[ColorEffects:Inactive]" + lf$ +_
"Color=112,111,110" + lf$ +_
"ColorAmount=0.025" + lf$ +_
"ColorEffect=2" + lf$ +_
"ContrastAmount=0.1" + lf$ +_
"ContrastEffect=2" + lf$ +_
"Enable=true" + lf$ +_
"IntensityAmount=0" + lf$ +_
"IntensityEffect=0" + lf$ + lf$

ani$ = ani$ + "[Colors:Button]" + lf$ +_
"BackgroundAlternate=" + sco(7) + lf$ +_
"BackgroundNormal=" + sco(6) + lf$ +_
"DecorationFocus=" + sco(11) + lf$ +_
"DecorationHover=" + sco(12) + lf$ +_
"ForegroundActive=" + sco(1) + lf$ +_
"ForegroundInactive=" + sco(11) + lf$ +_
"ForegroundLink=" + sco(5) + lf$ +_
"ForegroundNegative=" + sco(5) + lf$ +_
"ForegroundNeutral=" + sco(5) + lf$ +_
"ForegroundNormal=" + sco(5) + lf$ +_
"ForegroundPositive=" + sco(5) + lf$ +_
"ForegroundVisited=" + sco(5) + lf$ +_
"" + lf$ +_
"[Colors:Complementary]" + lf$ +_
"BackgroundAlternate=196,224,255" + lf$ +_
"BackgroundNormal=24,21,19" + lf$ +_
"DecorationFocus=58,167,221" + lf$ +_
"DecorationHover=110,214,255" + lf$ +_
"ForegroundActive=255,128,224" + lf$ +_
"ForegroundInactive=137,136,135" + lf$ +_
"ForegroundLink=88,172,255" + lf$ +_
"ForegroundNegative=191,3,3" + lf$ +_
"ForegroundNeutral=176,128,0" + lf$ +_
"ForegroundNormal=231,253,255" + lf$ +_
"ForegroundPositive=0,110,40" + lf$ +_
"ForegroundVisited=150,111,232" + lf$ +_
"" + lf$ +_
"[Colors:Selection]" + lf$ +_
"BackgroundAlternate=" + sco(3) + lf$ +_
"BackgroundNormal=" + sco(4) + lf$ +_
"DecorationFocus=" + sco(3) + lf$ +_
"DecorationHover=" + sco(4) + lf$ +_
"ForegroundActive=" + sco(10) + lf$ +_
"ForegroundInactive=" + sco(9) + lf$ +_
"ForegroundLink=" + sco(10) + lf$ +_
"ForegroundNegative=" + sco(10) + lf$ +_
"ForegroundNeutral=" + sco(8) + lf$ +_
"ForegroundNormal=" + sco(10) + lf$ +_
"ForegroundPositive=" + sco(10) + lf$ +_
"ForegroundVisited=" + sco(8) + lf$ +_
"" + lf$ +_
"[Colors:Tooltip]" + lf$ +_
"BackgroundAlternate=196,224,255" + lf$ +_
"BackgroundNormal=192,218,255" + lf$ +_
"DecorationFocus=43,116,199" + lf$ +_
"DecorationHover=119,183,255" + lf$ +_
"ForegroundActive=255,128,224" + lf$ +_
"ForegroundInactive=96,112,128" + lf$ +_
"ForegroundLink=0,87,174" + lf$ +_
"ForegroundNegative=191,3,3" + lf$ +_
"ForegroundNeutral=176,128,0" + lf$ +_
"ForegroundNormal=20,19,18" + lf$ +_
"ForegroundPositive=0,110,40" + lf$ +_
"ForegroundVisited=69,40,134" + lf$ +_
"" + lf$ +_
"[Colors:View]" + lf$ +_
"BackgroundAlternate=" + sco(7) + lf$ +_
"BackgroundNormal=" + sco(6) + lf$ +_
"DecorationFocus=" + sco(11) + lf$ +_
"DecorationHover=" + sco(12) + lf$ +_
"ForegroundActive=" + sco(1) + lf$ +_
"ForegroundInactive=" + sco(11) + lf$ +_
"ForegroundLink=" + sco(3) + lf$ +_
"ForegroundNegative" + sco(3) + lf$ +_
"ForegroundNeutral=" + sco(4) + lf$ +_
"ForegroundNormal=" + sco(1) + lf$ +_
"ForegroundPositive=" + sco(4) + lf$ +_
"ForegroundVisited=" + sco(5) + lf$ +_
"" + lf$ +_
"[Colors:Window]" + lf$ +_
"BackgroundAlternate=" + sco(7) + lf$ +_
"BackgroundNormal=" + sco(6) + lf$ +_
"DecorationFocus=" + sco(11) + lf$ +_
"DecorationHover=" + sco(12) + lf$ +_
"ForegroundActive=" + sco(1) + lf$ +_
"ForegroundInactive=" + sco(11) + lf$ +_
"ForegroundLink=" + sco(3) + lf$ +_
"ForegroundNegative" + sco(3) + lf$ +_
"ForegroundNeutral=" + sco(4) + lf$ +_
"ForegroundNormal=" + sco(1) + lf$ +_
"ForegroundPositive=" + sco(4) + lf$ +_
"ForegroundVisited=" + sco(5) + lf$ +_
"" + lf$ +_
"[General]" + lf$ +_
"Name=randomcolorscheme" + Zeroes$(w, 2) + lf$ +_
"shadeSortColumn=true" + lf$ + lf$ +_
"[KDE]" + lf$ +_
"contrast=4" + lf$ + lf$ +_
"[WM]" + lf$ +_
"activeBackground=" + sco(7) + lf$ +_
"activeForeground=" + sco(5) + lf$ +_
"inactiveBackground=224,223,222" + lf$ +_
"inactiveForeground=20,19,18" + lf$

a$ = environ$("HOME") + "/.local/share/color-schemes/randomcolorscheme" + Zeroes$(w, 2) + ".colors"
ff = freefile
open a$ for output as ff
print #ff, ani$
close ff
print w

next  'w
print "FINISHED"
system


'CHANGED: rr, gg, bb
function lightcolor$ ()
    dim as integer rr, gg, bb
    rr = Rand(192, 255)
    gg = Rand(192, 223)
    bb = Rand(224, 255)
    if Random1(3) = 1 then gg = gg + 16
    if Random1(3) = 1 then gg = gg + 16
    if Random1(2) = 1 then swap rr, bb
    if Random1(2) = 1 then swap gg, bb
    if Random1(2) = 1 then swap rr, gg
    if Random1(2) = 1 then swap rr, bb
    if Random1(2) = 1 then swap gg, bb
    lightcolor$ = _trim$(str$(rr)) + "," + _trim$(str$(gg)) + "," + _trim$(str$(bb))
end function

function darkcolor$ ()
    dim as integer rr, gg, bb
    rr = Random1(64)
    gg = Rand(48, 79)
    bb = Rand(48, 95)
    if Random1(3) = 1 then gg = gg + 16
    if Random1(4) = 1 then gg = gg + 32
    if Random1(2) = 1 then swap rr, bb
    if Random1(2) = 1 then swap gg, bb
    if Random1(2) = 1 then swap rr, gg
    darkcolor$ = _trim$(str$(rr)) + "," + _trim$(str$(gg)) + "," + _trim$(str$(bb))
end function

function twincolor$ ()
    dim as integer rr, gg, bb, xx, yy
    dim sret as string
    rr = Rand(224, 255)
    gg = Rand(224, 239)
    bb = Rand(248, 255)
    xx = Random1(80)
    yy = Random1(80)
    if Random1(3) = 1 then gg = gg + 16
    if Random1(2) = 1 then swap rr, bb
    if Random1(2) = 1 then swap gg, bb
    if Random1(2) = 1 then swap rr, gg
    if Random1(2) = 1 then swap rr, bb
    if Random1(2) = 1 then swap gg, bb
    sret$ = _trim$(str$(rr)) + "," + _trim$(str$(gg)) + "," + _trim$(str$(bb)) + "|"
    select case Random1(6)
        case 1 : rr = xx : gg = yy
        case 2 : gg = xx : bb = yy
        case 3 : rr = xx : bb = yy
        case 4
            swap rr, bb
            rr = xx : gg = yy
        case 5
            swap rr, gg
            gg = xx : bb = yy
        case 6
            swap gg, bb
            rr = xx : bb = yy
    end select
    sret$ = sret$ + _trim$(str$(rr)) + "," + _trim$(str$(gg)) + "," + _trim$(str$(bb))
    twincolor$ = sret$
end function

FUNCTION Random1& (maxvaluu&)
DIM sg%
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
    Random1& = 0
ELSE
    IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
    Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION

FUNCTION Rand& (fromval&, toval&)
DIM f&, t&, sg%
IF fromval& = toval& THEN
    Rand& = fromval&
    EXIT FUNCTION
END IF
f& = fromval&
t& = toval&
IF (f& < 0) AND (t& < 0) THEN
    sg% = -1
    f& = f& * -1
    t& = t& * -1
ELSE
    sg% = 1
END IF
IF f& > t& THEN SWAP f&, t&
Rand& = INT(RND * (t& - f& + 1) + f&) * sg%
END FUNCTION

FUNCTION Zeroes$ (num AS LONG, numdig AS INTEGER)
dim as _byte sg, hx
dim b$, v as long
IF num < 0 THEN sg = -1: num = num * -1
IF numdig < 0 THEN hx = 1: numdig = numdig * -1 ELSE hx = 0
IF hx THEN
    b$ = HEX$(num)
ELSE
    b$ = LTRIM$(STR$(num))
END IF
v = numdig - LEN(b$)
IF v > 0 THEN b$ = STRING$(v, 48) + b$
IF sg = -1 THEN b$ = "-" + b$
Zeroes$ = b$
END FUNCTION

[Image: plasma-colors-bas-prog.png]
Reply


Messages In This Thread
Linux only: random dark modes for KDE - by mnrvovrfc - 05-09-2023, 11:10 PM



Users browsing this thread: 1 Guest(s)