Ahora que? otro notificador (De espacios de trabajo JWM)

Post Reply
User avatar
nilsonmorales
Posts: 205
Joined: Thu Dec 26, 2019 1:47 am
Location: El Salvador
Has thanked: 78 times
Been thanked: 134 times
Contact:

Ahora que? otro notificador (De espacios de trabajo JWM)

Post by nilsonmorales »

He eliminado por completo los cuadros de los workspaces o espacios de trabajo de la bandeja del sistema de Puppy con jwm, y he agregado un script notificador en yad creado por un usuario de telegram asi tengo un panel mas limpio.
Descarga y descomprime en /root/.icons/
https://u.pcloud.link/publink/show?code ... 203ktMabDV
crea un script y colocalo en /root/Startup
ws-notifier.sh

Code: Select all

#! /usr/bin/env bash

############# DEBUGGING ################################################

#trap 'printf "\n" ; s=$?; echo >&2 "$0: Exit code on line "$LINENO": $BASH_COMMAND" ; exit $s ;' ERR
set -eou pipefail
#set -x

trap 'on_exit' EXIT


############# FUNCTIONS #################################################

# Get the Virtual Workspace
function get_virtual_desktop(){


    # Get the Virtual Desktop number
    local vd="$(wmctrl -d | grep "*" | awk '{ printf("%s", $1) }')"
    
    # print the Virtual Desktop number
    printf "%s" "$vd"
    

}



############ SCRIPT STARTS DOING THINGS #######################################

export script_pid=$$

# create a FIFO file, used to manage the I/O redirection from shell
export PIPE="$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)"
mkfifo "$PIPE"

# attach a file descriptor to the file
exec 3<> $PIPE
# add handler to manage process shutdown, I'm not sure if this function
# can be declared before creating the named pipe, and associating it to the FD 3
# so we leave it here for that reason
function on_exit() {
    
    rm -f "$PIPE"

}

export -f on_exit

function on_click(){

    kill -9 "$YAD_PID"
    kill -9 "$script_pid"
    rm -f "$PIPE"
    
    exit 0
}

export -f on_click

# Indicator or Notification Icon, it shows the tray being currently used
ws_icon=""
# Notification icons directory location
dir_icon="/root/.icons/ws-numbers"

# An associative array to help choose the proper notification icon
declare -A wsi
wsi["0"]="we_01.svg"
wsi["1"]="we_02.svg"
wsi["2"]="we_03.svg"
wsi["3"]="we_04.svg"
wsi["4"]="we_05.svg"
wsi["5"]="we_06.svg"
wsi["6"]="we_07.svg"
wsi["7"]="we_08.svg"
wsi["8"]="we_09.svg"
wsi["9"]="we_10.svg"

# The work space being used when the script is launched
current_workspace="$(get_virtual_desktop)"
# set the icon to the corresponding working space
ws_icon="${wsi[$current_workspace]}"

tooltip_ws=$(($current_workspace + 1))

# Create the notification icon using yad
yad --notification                  \
    --listen                        \
    --icon-size=48                  \
    --image="${dir_icon}/${ws_icon}"\
    --text="Workspace $tooltip_ws"   \
    --command="bash -c on_click" <&3 &

# update the icon by constatly checking any changes in the working space
while true ; do
    
    new_workspace="$(get_virtual_desktop)"
    
    tooltip_ws=$(($new_workspace + 1))
    
    if [[ $new_workspace -gt 9 ]] ; then
        
        ws_icon="error.svg"
        
        echo "icon:$dir_icon/$ws_icon" >> "$PIPE"
        
        echo "tooltip:workspace $tooltip_ws" >> "$PIPE"
        
        echo "action:bash -c on_click" >> "$PIPE"
        
    fi
    
    if [[ $current_workspace -ne $new_workspace ]]; then
        
        ws_icon="${wsi[$new_workspace]}"
        
        echo "icon:$dir_icon/$ws_icon" >> "$PIPE"
        
        echo "tooltip:workspace $tooltip_ws" >> "$PIPE"
        
        echo "action:bash -c on_click" >> "$PIPE"
        
        
    fi
    
    current_workspace="$new_workspace"
    
    sleep 2s  # Agregamos un retraso adicional antes de volver a verificar el cambio de espacio de trabajo
    
done

exit 0

Image
la imagen muestra 2 notificadores, uno en el esritorio otro en el panel, el de arriba es de el panel el del escriotrio es este:
switch-wspace

Code: Select all

#!/bin/sh
# Description: Using yad to pop-up the current workspace number when changing workspaces
# Requires: wmctrl, yad 
font="TerminessNerdFont" 
CURRENT_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1))
while true
do
 NEW_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1)) 
 if [ $CURRENT_WORKSPACE -ne $NEW_WORKSPACE ]; then
  (yad --skip-taskbar --form --timeout=3 --no-buttons --undecorated \
      --columns="1" --on-top --geometry=20x20-40-40 \
      --field="<span color='#607D8B' font='$font 36'>$NEW_WORKSPACE</span>!!:fbtn" "" \ &)
  CURRENT_WORKSPACE=$NEW_WORKSPACE
 fi
 sleep 2  # Agregamos un retraso adicional antes de volver a verificar el cambio de espacio de trabajo
done
exit 0

Esto es repetido pero quiero separarlo de mis temas globales de personalización de bookwormpup ya que puede ser útil para otrs puppies, la forma de configuración esta ahi el enlace original viewtopic.php?p=122811#p122811

Post Reply

Return to “Usuarios de habla Hispana”