Ir para o conteúdo

OpenBSD : Configurando o XenoDM

1 - Entendendo e Configurando o XenoDM

Com a atualização do OpenBSD 6.4 para -current ( 6.5 beta ) acabei esbarrando na obrigação de usar o xenodm como display manager :

xenodm.png

Não o login mais bonito do mundo, não é ? É exatamente por isso que resolvi dar uma modificadinha. Nos blgos do tumfatig e do Zolatorev peguei umas dicas bem legais.

1.1 - Estrutura do xenodm

Os arquivos de configuração do xenodm ficam no /etc/X11/xenodm :

/etc/X11/xenodm/
|-- GiveConsole
|-- TakeConsole
|-- Xreset
|-- Xresources
|-- Xservers
|-- Xsession
|-- Xsetup_0
|-- Xstartup
|-- authdir/
|   `-- authfiles/
|-- pixmaps/
|   |-- OpenBSD_15bpp.xpm
|   |-- OpenBSD_1bpp.xpm
|   |-- OpenBSD_4bpp.xpm
|   `-- OpenBSD_8bpp.xpm
`-- xenodm-config

Pelo que entendi, o arquivo principal é o xenodm-config. É ele que utiliza dos demais arquivos para executar o xenodm. Vou modificar 3 arquivos : GiveConsole,Xresources e Xsetup_0.

1.2 - Xsetup_0

Este arquivo é um shell script usado como se fosse o .xinitrc do xenodm. O meu ficou desse jeito :

#!/usr/local/bin/bash
xrandr --output default --dpi 96

# requires pkg_add terminus-font
xset fp+ /usr/local/share/fonts/terminus

XRES=$(xrdb -query)

# set background color
BG_COLOR=$(echo "$XRES" | awk '/xroot.background/ { print $2 }')
xsetroot -solid $BG_COLOR

# show the date and time as two different widgets
for CLK in date time ;
do
    FACE=$(echo "$XRES" | grep "xclock.${CLK}Face" | xargs | cut -d ' ' -f 2-) ;
    GEOM=$(echo "$XRES" | grep "xclock.${CLK}Geom" | xargs | cut -d ' ' -f 2-) ;
    STR=$(echo "$XRES"  | grep "xclock.${CLK}Str" | xargs | cut -d ' ' -f 2-) ;

  xclock -face "$FACE" -geometry "$GEOM" -strftime "$STR" &
done

# show message just for fun
MSG=/home/wolf/src/scripts/hello_friend.sh
xterm -uc -fa "Terminus:pixelsize=32" \
      -geometry 20x2+0+0 \
      -bg rgb:25/21/23 \
      -fg rgb:ed/f6/e6 ${MSG} &

# show the Sleep / Restart / Shutdown bar
# in case of sleep, pop xmessage again after waking up
(
while true ;
do
  xmessage -geometry +540-32 \
           -buttons "[ Sleep ]":20,"[ Restart ]":21,"[ Shutdown ]":22 ""
  ACTION=$?
  echo "Xmessage said: $ACTION"
  if [ $ACTION -eq 20 ] ;
      then
              /usr/sbin/zzz ;
      elif [ $ACTION -eq 21 ] ;
      then
              xsetroot -cursor_name watch ;
              /sbin/shutdown -r now ;
      elif [ $ACTION -eq 22 ];
      then
          xsetroot -cursor_name watch ;
          /sbin/shutdown -p now ;
      else
              echo "Something bad happened to Xmessage.";
  fi
  # stop looping if xclock died (hopefully killed by GiveConsole)
  if [ -z "$(pgrep -U root xclock)" ]; then break; fi
done
) &

1.3 - Xresources

Esse Xresources ( dentro de /etc/X11/xenodm/ ) serve para configurar os programas que vamos usar durante a tela de login. No meu caso fiz uso de 4 componentes :

  1. XLogin ;
  2. XMessage ;
  3. XClock ;
  4. XTerm;

Abaixo está a configuração :

! ----------------------------------------------------------------------
! Colors
!

#define  WHITE    #EDF6E6
#define  BLACK    #252123
#define  RED      #DA8B9A
#define  BLUE     #7AADD9
#define  BROWN    #6E6967
#define  DKBROWN  #54504F
#define  DKBLUE   #6187AD
#define  GREY     #54697F
#define  DKGREY   #4A566B


DisplayManager*terminateServer: true

xroot.background: BLACK

! ----------------------------------------------------------------------
!
Xcursor.size: 6

! ----------------------------------------------------------------------
! Xlogin

xlogin.Login.allowRootLogin: false


xlogin.Login.echoPasswd:   false
xlogin.Login.fail:         Authorization failed
xlogin.Login.greeting:     This is 54807463
xlogin.Login.namePrompt:   \040\040\040Login:\040
xlogin.Login.passwdPrompt: Password:\040

xlogin.geometry: 430x200+180+360
xlogin*borderWidth:            0
xlogin.Login.frameWidth:       0
xlogin.Login.innerFramesWidth: 1
xlogin.Login.sepWidth:         0


xlogin.Login.background:  BLACK
xlogin.Login.failColor:   RED
xlogin.Login.foreground:  WHITE
xlogin.Login.greetColor:  WHITE
xlogin.Login.inpColor:    BLACK
xlogin.Login.promptColor: WHITE
xlogin.Login.hiColor:     WHITE
xlogin.Login.shdColor:    WHITE

xlogin.Login.face:       Terminus-14
xlogin.Login.failFace:   Terminus-18:bold
xlogin.Login.greetFace:  Terminus-10
xlogin.Login.promptFace: Terminus-14

! ----------------------------------------------------------------------
! XClock
!


xclock.dateFace:         Terminus-18:bold
xclock.dateGeom:         +780+360
xclock.dateStr:          %A %d %B %Y

xclock.timeFace:         Terminus-32:bold
xclock.timeGeom:         +780+430
xclock.timeStr:          %H:%M

xclock*background:       BLACK
xclock*borderWidth:      0
xclock*foreground:       WHITE

xclock.Clock.analog:     false
xclock.Clock.chime:      false
xclock.Clock.render:     true
xclock.Clock.twentyfour: true
xclock.Clock.update:     10



! ----------------------------------------------------------------------
! XMessage
!

xmessage*background: BLACK
xmessage*foreground: WHITE
xmessage*borderWidth: 0
xmessage*font: Terminus-16:bold 
xmessage*message.scrollHorizontal: Never
xmessage*message.scrollVertical: Never
xmessage*timeout: 0

! ----------------------------------------------------------------------
! XTerm
!

XTerm*background: rgb:ED/F6/E6
Xterm*foreground: rgb:25/21/23
XTerm.vt100.scrollBar: false
XTerm.vt100.saveLines: 0
XTerm*cursorUnderline: true
XTerm*cursorOffTime: 200
XTerm*cursorOnTime: 200
XTerm*transparent:true
XTerm*borderWidth:0

1.4 - GiveConsole

O GiveConsole é o script que é executado quando há um login bem sucedido. Nele tomei o cuidado de encerrar os 3 outros componentes além do XLogin :

#!/bin/sh
# Assign ownership of the console to the invoking user
# $OpenBSD: GiveConsole,v 1.2 2018/07/11 19:20:40 matthieu Exp $
#
# By convention, both xconsole and xterm -C check that the
# console is owned by the invoking user and is readable before attaching
# the console output.  This way a random user can invoke xterm -C without
# causing serious grief.
#

pkill xclock
pkill xmessage
pkill xterm


chown $USER /dev/console
if [ -c /dev/drm0 ]; then
    chown $USER /dev/drm0
fi
/usr/X11R6/bin/sessreg -a -l $DISPLAY -u none $USER

E esse xterm aí ? Bem, nele eu coloquei um script jogando um "hello friend", só pra deixar o OpenBSD mais amigável :

#!/bin/sh

c=1 ;
for char in h e l l o f r i e n d ;
do
    sleep 0.25 ;
    if [ ${c} = 5 ] ;
    then
        printf "%s" ${char} ;
        printf " " ;
    elif [ ${c} = 11 ]
    then
        printf "%s " ${char} ;
        read ;
    else
        printf "%s" ${char} ;
    fi ;
    let c++ ;
done;

O resultado final ficou até bom :

hello_friend.png

Er.. Eu ainda não sei como pegar algo da sessão do XenoDM.