Dk scratch with urxvt or alacritty instead of st

Hi all!
I have been very sick for a week in covid and finally I can breath again (at least a bit and I am starting to have hope that I will survive this time)

I was wondering if there is a way to use that scratch.sh script with alacritty or urxvt instead of st?
I am very interested in scripting but my knowledge is still very weak. (slow and old learner but I hopefully have time!)

womp

1 Like

Change the cmd variable.

From the script:

# these can be edited by the user to be any window, just make sure to set the class
# to our title using whatever flag is needed: --class, -c, etc.
title="scratchpad"
cmd=(
	st -c "$title"
)

Change:

st -c "$title"

to whatever the equivalent flag would be to set the class for your terminal of choice. The man pages for urxvt and alacritty will have the information you need to define the class.

3 Likes

Great to have you with us again @womp ! Hang on in there, it will get better.

2 Likes

Hope you are feeling better @womp

1 Like

Get well soon mate !

1 Like

Thank you very much guys!!

womp

2 Likes

Thank you for trying to help!!
I have now read thru man urxvt and according to that tried

urxvt --class URxvt,URxvt -e "$title"

I get a screen flicker for a second but nothing else.

I am rather weak and will rest and try again later!

womp

Hope your well soon…
I don’t use Alacritty I use kiitty but the same should work.

dkrc
dkcmd rule class="^scratchpad$" float=true x=800 y=28 w=1000 h=600

sxhkdrc
super + shift + d
     kitty --class scratchpad

Try

urxvt --class "$title"
2 Likes

Back from resting a few hours.

urxvt --class "$title"

Does not do anything.

alacritty --class "$title"

Opens alacritty and splits screen. (no floating and then useless as a scratch)

urxvt use -e in some way that I do not understand yet.

womp

1 Like

Hi again. I may have solved it with alacritty!

In scratch.sh

	alacritty --class "$title"

and in dkrc created a rule for alacritty opening as floating.

dkcmd rule class=alacritty float=true w=650 h=400

Alacritty is working very well as scratch now! It’s also very fast and working scrollback without patching.
Now I will try to get urxvt to work as a scratch.
Got to rest a bit more first though.

womp

3 Likes

You’ve done it again @womp :wink: Now rest, every day a step !

2 Likes

Urxvt doesn’t seem to have the --class flag.

It might use --name instead:

urxvt --name "$title"
2 Likes

Hi again!

Been sleeping and fiddling!

I saw yesterday that AL has a new “edition”! I downloaded and installed it on a very old workstation. I built it myself 5-6 years ago (from spare parts) but it was old aldready then. 1st gen Intel-I-5 and a very old Nvidia card. (I go with nouveau)
I installed just for running dkwm (and maybe dwm).
The motherboard is partially broken so I have to use a wifi-dongle.
AL picked up everything and installation went very smooth and fast. It took not more than 10 minutes and there are no SSDs.
I had some minor problems setting up dkwm on reboot but after switching to polybar (and one of “my own” configs) it’s running very well! Dkwm is now top of the list. It took me about 10-15 minutes to setup dkwm and still have most of the fancy stuff that other wms have. My old “no-name” workstation (org. Vista-machine) is alive!

I am very thankful!!

womp

-e It is just execute.

urxvt manual…

-e command [arguments]

Run the command with its command-line arguments in the urxvt window; also sets the window title and icon name to be the basename of the program being executed if neither -title (-T) nor -n are given on the command line. If this option is used, it must be the last on the command-line. If there is no -e option then the default is to run the program specified by the SHELL environment variable or, failing that, sh(1).

Please note that you must specify a program with arguments. If you want to run shell commands, you have to specify the shell, like this:

urxvt -e sh -c “shell commands”

1 Like

I changed my scratchpad to the dk script scratch.sh the newer script. kitty with floating

dkrc
dkcmd rule class=“^/home/koo/.config/dk/scripts/scratch.sh$” float=true x=800 y=28 w=1000 h=600

sxhkdrc
super + shift + d
kitty --class ~/.config/dk/scripts/scratch.sh

#!/bin/bash

# basic scratchpad functionality for dk
# spawns a set command with a known title if not already open
# if open toggle between the current workspace and the last
# written by Nathaniel Maia - 2021

# example rule for the below script to be placed in your dkrc
#    dkcmd rule class="^scratchpad$" float=true

# these can be edited by the user to be any window, just make sure to set the class
# to our title using whatever flag is needed: --class, -c, etc.
title="scratchpad"
cmd=(
	kitty --class "$title"
)


# window ID, we need to printf it as 8 hex digits to later match with dk status
win=$(printf '0x%08x' "$(xwininfo -root -children | awk '/'"$title"'/ {print $1}')")

if (( win != 0 )); then
	# window is already open so toggle it
	stat=$(dkcmd status num=1 type=full)
	ws=$(awk '/^workspaces:/ { for (i = 1; i <= NF; i++) { if ($i ~ "*") print i - 1 } }' <<< "$stat")
	wins=$(sed -n '/^windows:/,/^$/p' <<< "$stat")
	win_ws=$(grep "^\s*${win}" <<< "$wins" | awk -F'" ' '{print $4}' | cut -d' ' -f1)

	if (( win_ws == ws )); then
		# hide it
		# we could create a new workspace and place it there instead to not mess with the users existing workspaces
		dkcmd ws send "$win" "$(awk '/numws/{print $2}' <<< "$stat")"
	else
		# show it
		dkcmd ws send "$win" "$ws"
	fi
else
	# the window is not yet spawned so do so
	"${cmd[@]}" &>/dev/null & disown
fi
2 Likes

Thatś what I am running. Works great!

womp

2 Likes

Would you give it a try? Another scratch script