#Need Assistance With Ricing

55 messages · Page 1 of 1 (latest)

gray haven
#

Hey guys! So I created this neat looking desktop, and I need assistance with booting them up automatically at start in the exact postions they are currently in. I can't seem to figure that part out (old screenshot btw. I managed to make it look cleaner) could anyone assist me with this? Thanks!

gentle seal
gentle seal
#

KWin, if the fetch is to be believed

hexed spindle
#

right right

#

yeah i suppose tmux/hollywood is the easiest solution in this case

#

if its hyprland you may be able to use autostart & windowrules to do this

gray haven
#

# Adjust these for your second monitor
OFFSET_X=1920
OFFSET_Y=0
MON_WIDTH=1920
MON_HEIGHT=1080

# Terminal to use (konsole works great with KDE)
TERM=konsole

# Function to position a window
position_window() {
    local window_id="$1"
    local x="$2"
    local y="$3"
    local w="$4"
    local h="$5"
    
    # Calculate absolute position
    abs_x=$(( OFFSET_X + x ))
    abs_y=$(( OFFSET_Y + y ))
    
    # Position and resize using Plasma's kwin script interface
    qdbus org.kde.KWin /KWin setWindowPosition "$$window_id" "$$abs_x" "$abs_y"
    qdbus org.kde.KWin /KWin setWindowSize "$$window_id" "$$w" "$h"
}

# Wait for a window to appear
wait_for_window() {
    local title="$1"
    local count=0
    while ! xdotool search --onlyvisible --name "$title" 2>/dev/null | head -1; do
        sleep 0.2
        ((count++))
        if [[ $count -gt 50 ]]; then
            echo "Timeout waiting for: $title"
            return 1
        fi
    done
    return 0
}

# Start programs in separate terminals
# Top row
$TERM -e bash -c "fastfetch; bash" &
wait_for_window "fastfetch" && position_window "$(xdotool getactivewindow)" $$OFFSET_X $$OFFSET_Y 640 360

$TERM -e bash -c "cmatrix; bash" &
wait_for_window "cmatrix" && position_window "$(xdotool getactivewindow)" $$((OFFSET_X + 640)) $$OFFSET_Y 640 360

$TERM -e bash -c "tty-clock; bash" &
wait_for_window "tty-clock" && position_window "$(xdotool getactivewindow)" $$((OFFSET_X + 1280)) $$OFFSET_Y 640 360

# Bottom row
$TERM -e bash -c "cava; bash" &
wait_for_window "cava" && position_window "$(xdotool getactivewindow)" $$OFFSET_X $$((OFFSET_Y + 360)) 960 720

$TERM -e bash -c "btop; bash" &
wait_for_window "btop" && position_window "$(xdotool getactivewindow)" $$((OFFSET_X + 960)) $$((OFFSET_Y + 360)) 960 720

install xdotool if needed

Make executable.

What do you think of this method? unless its exactly the same thing that is in that link you sent

gentle seal
#

note that the hollywood thing i sent you would run everything in one terminal window which might look better

gray haven
gentle seal
#

using tmux

gray haven
#

.......huh

#

interesting

#

I'd say, its not the fact that it looks better, but rather, more convenient

gray haven
gentle seal
gray haven
#

Interesting. Okay, I'll take a look at this as well. Thanks!

gentle seal
#

yw

hexed spindle
#

Seems like it depends on a whole lot of x11 tools

gray haven
#

I use Plasma X11 so I'm not sure....let me check.

#

Yeah it seems as if there are some alternatives to where you can run something similar on Wayland, but what I pasted would not work at all on Wayland

gray haven
#

i just got time to work on it

gray haven
#

It's so annoying

gentle seal
#

oh

#

yeah hollywood randomly chooses what goes where

#

and kwin is not intended for what youre doing with it

gray haven
gentle seal
#

idk

#

or sway

gray haven
#

Alright. I got it

#

Now it boots up like this automatically

#

it soooo nice

#

took some scripting and a bit of screaming and cussing at AI, but we got it working finally.

gentle seal
gray haven
#

like the script itself?

gentle seal
gray haven
# gentle seal yea

sleep 5

BASE_X=3440
BASE_Y=191

TOP_W=640
TOP_H=540
BOT_W=960
BOT_H=540

PAD_W=0
PAD_H=0

TOP_W_ADJ=$((TOP_W - PAD_W))
TOP_H_ADJ=$((TOP_H - PAD_H))
BOT_W_ADJ=$((BOT_W - PAD_W))
BOT_H_ADJ=$((BOT_H - PAD_H))

OVERLAP=2

start_konsole_pid() {
  konsole --separate -e bash -lc "$*" >/dev/null 2>&1 &
  echo $!
}

winid_from_pid() {
  local PID="$1"
  for i in {1..80}; do
    local ID
    ID=$(xdotool search --pid "$PID" 2>/dev/null | head -n 1)
    if [ -n "$ID" ]; then
      echo "$ID"
      return 0
    fi
    sleep 0.2
  done
  return 1
}

move_resize_id() {
  local ID="$1"
  local X="$2"
  local Y="$3"
  local W="$4"
  local H="$5"
  xdotool windowmove "$ID" "$X" "$Y"
  xdotool windowsize "$ID" "$W" "$H"
}

PID_FASTFETCH=$(start_konsole_pid "clear; fastfetch; exec bash")
PID_CMATRIX=$(start_konsole_pid "exec cmatrix")
PID_TTYCLOCK=$(start_konsole_pid "exec tty-clock -s -c -C 6")
PID_CAVA=$(start_konsole_pid "exec cava")
PID_BTOP=$(start_konsole_pid "exec btop")

ID_FASTFETCH=$(winid_from_pid "$PID_FASTFETCH")
ID_CMATRIX=$(winid_from_pid "$PID_CMATRIX")
ID_TTYCLOCK=$(winid_from_pid "$PID_TTYCLOCK")
ID_CAVA=$(winid_from_pid "$PID_CAVA")
ID_BTOP=$(winid_from_pid "$PID_BTOP")

move_resize_id "$ID_FASTFETCH" "$BASE_X" "$BASE_Y" "$TOP_W_ADJ" "$TOP_H_ADJ"
move_resize_id "$ID_CMATRIX" "$((BASE_X + 640 - OVERLAP))" "$BASE_Y" "$TOP_W_ADJ" "$TOP_H_ADJ"
move_resize_id "$ID_TTYCLOCK" "$((BASE_X + 1280 - OVERLAP*2))" "$BASE_Y" "$TOP_W_ADJ" "$TOP_H_ADJ"

move_resize_id "$ID_CAVA" "$BASE_X" "$((BASE_Y + 540 - OVERLAP))" "$BOT_W_ADJ" "$BOT_H_ADJ"
move_resize_id "$ID_BTOP" "$((BASE_X + 960 - OVERLAP))" "$((BASE_Y + 540 - OVERLAP))" "$BOT_W_ADJ" "$BOT_H_ADJ"```
#

Then added some Window Rules to remove the titlebars and frames, added the script to "Startup Applications" and done.

gentle seal
#

huh

#

that should be hardcoded i don't know why it takes so much code to do that

gray haven
#

beats me...I tried everything and it was giving me a headache

#

so, this ended up working, then I said "ight, I'm not touching it anymore. we good"

gentle seal
#

i just dont know why they designed it so badly

gray haven
#

you sure its not an abandoned project?

gentle seal