Ah that’s useful to know, thanks!
I was working on my .bashrc
and reading about its posibilities. So, I thought I should make something totaly useless.
Put this code to your .bashrc and press F12 in your termianl window (works in tty too).
bind '"\C-k":kill-whole-line' # clear current input line (Ctrl+k default is 'kill-line')
#F12 cowsay info
alias cowinfo='echo -ne "Who am I?\t$(whoami)\nWhere am I?\t$(pwd)\nWhen am I?\t$(date "+%T %d.%m.%Y")\nWhat'\''s this?\t$(uname -n)\nWhat'\''s on it?\t$(uname -sr)\n\n$(fortune)" | cowsay -n'
bind '"\e[24~":"\C-kcowinfo\n"'
You need cowsay
and fortune-mod
packages for it to work.
Result on my Ubuntu machine.
________________________________________
/ Who am I? vlkon \
| Where am I? /home/vlkon |
| When am I? 23:08:12 13.09.2020 |
| What's this? portable |
| What's on it? Linux 5.4.0-47-generic |
| |
\ The bug starts here. /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
As a sidenote this might be a handy way how to map commonly used commands to a key without DE. It is basicaly the same as listing it in inputrc file.
With a little modification it will make neofetch
obsolete.
I was reinventing .desktop files in i3wm.
It lists predefined entries in dmenu
based on existence of a specific file.
It would be much better to wrap each application to a package but since I use this mostly with wine
appliations (games) I just copy whole folder with .exe launcher to wine/c_drive directory and it is ready - no stray files anywhere.
I have this in my .local/bin.
games
#!/bin/bash
# data array has to be in a format
# "name:path:exec_prefix:exec:exec_suffix"
# colons are important
# exec is launcher file that has to exist
###################################################
# Entry list
###################################################
entry=(
#"name:\
#path:\
#exec_prefix:\
#exec:\
#exec_suffix\
#"
#example
"crusader kings 2:\
${HOME}/hdd35/wine32/drive_c/hry/Crusader_Kings_II/:\
env WINEPREFIX=${HOME}/hdd35/wine32/ WINEDEBUG=fixme-all,err-all,warn+heap,trace-all wine :\
${HOME}/hdd35/wine32/drive_c/hry/Crusader_Kings_II/CK2game.exe:\
"
"ftl:\
${HOME}/games/ftl/:\
:\
${HOME}/games/ftl/start.sh:\
"
#end of entry
)
###################################################
# Main code
###################################################
# get dmenu theme
if ! [ -f "$HOME/.config/dmenurc" ]; then
cp /usr/share/dmenu/dmenurc $HOME/.config/dmenurc
fi
. $HOME/.config/dmenurc
# sorts entry array alphabetically
IFS=$'\n' data=($(sort <<<"${entry[*]}"));unset IFS
# build dmenu list (only from existing valid entries)
d_entry=""
for d in "${data[@]}"; do
name=$(echo "${d}" | awk -F: ' { print $1 } ')
path=$(echo "${d}" | awk -F: ' { print $2 } ')
exec=$(echo "${d}" | awk -F: ' { print $4 } ')
if [[ -d "${path}" && -f "${exec}" ]];then
d_entry="${d_entry}${name}\n"
fi
done
# get user input from the dmenu list
slection=$(echo -e "${d_entry}" | sed '/^$/d' | dmenu $DMENU_OPTIONS -p games: "$@")
# match user input and run exec
for d in "${data[@]}"; do
name=$(echo "${d}" | awk -F: ' { print $1 } ')
if [[ "${name}" == "${slection}" ]]; then
path=$(echo "${d}" | awk -F: ' { print $2 } ')
exec_prefix=$(echo "${d}" | awk -F: ' { print $3 } ')
exec=$(echo "${d}" | awk -F: ' { print $4 } ')
exec_suffix=$(echo "${d}" | awk -F: ' { print $5 } ')
full_exec="${exec_prefix}${exec}${exec_suffix}"
(cd "${path}"; bash -c "${full_exec}" > /dev/null 2>&1 &)
break
fi
done
Forgot to post the actual script…:
#!/bin/bash
RCUO=$(ps -e -o pid,comm | grep -w -E 'rcuo[a-z]\/[0-9]+' | awk '{ print $1 }' | tr '\n' ',' | head -c-1)
IFS=',' read -r -a ARRAY <<< "$RCUO"
for i in "${ARRAY[@]}"
do
taskset -cp 4,16 "$i"
done