Code Monkey home page Code Monkey logo

sx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sx's Issues

Installation

So I'm messing around in a minimal Debian VM that I started as just a server, but I wanted to play with installing a minimal graphical interface to it....this sounds like the perfect candidate to launch xorg......

The issue is, I don't know what make PREFIX=/usr DESTDIR=staged install means. I'm assuming I'll need build-essentials, but beyond that:

  • Do I need to download this to anywhere specific?
  • Do I just cd into that directory and enter that exactly?
  • Once I log into my user account, will I just need to enter the command sx and X will go?
  • Also curious what the sxrc file is supposed to look like

Thanks in advance for whatever patience you can spare for a noob.

P.S. If I'm able to grasp this, I'd be glad to attempt to write some documentation for your wiki tab for other less experienced folks

xrdb in the sx script doesn't work

In my ~/.config/Xresources file I have

Xft.dpi: 192

and in my sx file I have

xrdb -merge ~/.config/Xresources

However the dpi is not set on start. running the command manually after start will correctly set the dpi

Typo in README

This line in the README file is incorrect:
"While XAUTHORITY is still honoured, $XDG_DATA_HOME/sx/xauthfile is ..."

The correct file name is xauthority. The man page use the correct name.

sx doesn't kill while loops

sx doesn't kill while loops inside sxrc or external scripts.

example:

# Statusbar loop
while true; do
   xsetroot -name "$( date +"%F %R" )"
   sleep 1m    # Update time every minute
done &

when I exit my WM (dwm) xsetroot says it can't open display 1 every minute. this issue doesn't happen on xinit.

--

distro: void linux
ver: 2.1.6

Can't suppress both stdout and stderr

As the title says, attempting to suppress both stdout and stderr causes X to never launch. If I only suppress one of the two, sx is able to launch Xorg fine.

i3lock not working using systemd service on as sleep hook

I have this systemd service file that I use as a screenlock:

[Unit]
Description=Lockscreen app launch before suspend
Before=sleep.target

[Service]
User=%i
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock

[Install]
WantedBy=suspend.target

This works well when used with startx. Even when I change the DISPLAY=:0 to DISPLAY=:1, it does nothing but I get no error message whatsoever from i3lock.

This may be a bug with the i3lock itself, but since it appeared only using this programme, I thought it might be more appropriate to put it here.

Are the `exec`s and the wait for the client (sxrc) really necessary?

Hi. It's me again. I hope I'm not bugging you.

Just in case I missed a chance to learn more, I read sx again and realize that I don't quite understand why we need to wait for the client process.

I tested it a bit myself. It seems that the wait is for some reason necessary if exec is used. Then I find the fact that exec (in both the client and the server case) is used is actually strange to me as well, because they are both forked.

What would be the potential pitfall(s) when it is done with:

...
trap 'DISPLAY=:$tty "${@:-$cfgdir/sxrc}" &' USR1

(trap '' USR1 && Xorg :"$tty" -keeptty vt"$tty" -noreset -auth "$XAUTHORITY") & pid=$!
...

?

applications fail with connection refused.

Run zathura from the terminal. Errors out with this:

No protocol specified
Unable to init server: Could not connect: Connection refused

(zathura:11): Gtk-WARNING **: 11:00:51.082: cannot open display: :1

server options

Hi. Currently the server command-line is hardcoded. Would it be possible to pass custom options to the server? I am specially interested in -ardelay, -arinterval and -xkbmap. Thank you.

Error: Can't open display: :0

I get this is terminal emacs when trying to copy something. I think the error comes from xclip. I'm starting sx from .profile:

#!/bin/sh
# .profile

if test -z "${XDG_RUNTIME_DIR}"; then
    XDG_RUNTIME_DIR=/tmp/"$(id -u)"-runtime-dir
    export XDG_RUNTIME_DIR
    if ! test -d "${XDG_RUNTIME_DIR}"; then
        mkdir "${XDG_RUNTIME_DIR}"
        chmod 0700 "${XDG_RUNTIME_DIR}"
    fi
fi

if [ -f ~/.bashrc ]; then . .bashrc; fi

if [ ! "$DISPLAY" ]; then
  sx sh ~/.xinitrc 2> .xsession-errors
  #startx 2> .xsession-errors
fi
#!/bin/sh

if [ -d /etc/X11/xinit ] ; then
  for f in /etc/X11/xinit/* ; do
    [ -x "$f" ] && . "$f"
    done
  unset f
fi

awesome
xrdb -merge ~/.Xresources

The BSDs will likely never work

Due to my design choice of coupling the tty number to Xorg's vt argument and DISPLAY value it may mean neither OpenBSD or FreeBSD will ever work.

The reason for this seems to be due to how FreeBSD and OpenBSD won't let the Xorg server take over an active tty. Instead it generates a cryptic error message telling us that (EE) Unrecognized option: vt0.

Additionally OpenBSD will not let users run ps -o tty= $$ so this approach isn't viable to start with either.

There are a few potential solutions to this, some which seem to be mutually exclusive between platforms.

  • The first, and easiest solution for FreeBSD and OpenBSD is to simply not specify the vt argument and let the Xorg server select one that is available. Unfortunately this doesn't work on Linux (when using rootless Xorg servers thanks to systemd-logind).
  • The second is to unconditionally increment the vt argument based on the tty number we get. However this is not a reliable heuristic as the second tty may also be used under FreeBSD which lands us back at square one.
  • Start using platform detection.

None of these are going to be viable. Instead FreeBSD and OpenBSD would probably take advantage of /etc/ttys which appears to offer a better approach to managing Xorg servers anyway. For OpenBSD specifically they also have xenodm(1) as well.

The trap handling is likely fragile

Under shells such as dash or mrsh the cleanup function will never be called if sx is interrupted by a signal. The bash (as sh) shell implements a strategy which does ensure it is called but it is the exception.

The only somewhat reliable interpretation of EXIT is that it will be run when the shell script itself exits normally, as if the function was called directly at the bottom of the script. This effectively makes the EXIT trap extraneous.

Due to this more thought is needed to handle signals that could interrupt sx such as INT and TERM especially if the cleanup function wants to call exit.

A potential implementation might be something like this:

cleanup() {
    r=$?

    # See notes below this example code.
    if [ "$r" -gt 128 ]; then
        signal=$((r - 128))
    fi

    if kill -0 "$pid" > /dev/null; then
        # Pass the signal to Xorg(?).  If the return was 0 above then this if
        # condition should not be met and the branch never taken.  If due to
        # any race conditions it is, then the call to kill will resolve to -0
        # and do nothing.
        kill -"$signal" "$pid"
        wait "$pid"
    fi

    if ! stty "$stty"; then
        stty sane
    fi

    xauth remove :"$tty"
}

# ...

for signal in HUP INT TERM; do
    # Resend the signal as they are intended to terminate the script as well.
    trap 'cleanup; trap - "$signal"; kill -s "$signal" "$$"' "$signal"
done

# ...

# Run the cleanup routine unconditionally at the end of the script, replacing
# the role of an EXIT trap.
cleanup

The use of 128 is not portable, and the POSIX standard renders it pointless:

The exit status of a command that terminated because it received a signal shall be reported as greater than 128.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02

Historically, shells have returned an exit status of 128+ n, where n represents the signal number. Since signal numbers are not standardized, there is no portable way to determine which signal caused the termination. Also, it is possible for a command to exit with a status in the same range of numbers that the shell would use to report that the command was terminated by a signal. Implementations are encouraged to choose exit values greater than 256 to indicate programs that terminate by a signal so that the exit status cannot be confused with an exit status generated by a normal termination.

https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_08

In the end I may simply do the clean up at the end of the script and simply do nothing with signals which will potentially leave Xservers running when they ought not be; either that or port this to bash instead.

why is xauth needed?

The xauth program is used to edit and display the authorization information used in connecting to the X server.

if removing this from the sx program still makes X function, why is it required as a dependency? is the XAUTHORITY and authentication for security purposes for Xorg applications?

gnome-keyring's ssh agent doesn't work

Starting i3 with config for gnome-keyring according to ArchWiki

dbus-update-activation-environment --systemd DISPLAY
eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK

startx works fine, but not sx.
Using sx still shows:

sign_and_send_pubkey: signing failed: agent refused operation

ps is not POSIX complient

The posix ps command does not take PID as a argument. This fails in busybox for example. One alternative is try command which POSIX. To get the try, we need to basename it

i3status doesn't show applet

Applet such as nm-applet aren't visible in i3status bar and even refuse showing when run form the command line.
In other window managers I tested (qtile, awesomee) the same issue appear.
Any clarification about why i3status is having problems with sx?

Why is sx so much simpler than startx

Hi. I just stumbled by mere accident over sx. I had a question about xinitrc and somebody suggested sx. It works really great and seems to be faster. Anyway, I was wondering how come that sx is so much simpler than startx? You dont have to explain if you dont have time but maybe you can give me at least some hints :)

Xorg server does not shutdown

If I leave my window manager the Xorg still runs and does not shutdown. I have to switch to tty2 and kill it. How can I solve this?

Cannot set environment variables in sxrc

Here is my ~/.config/sx/sxrc:

#!/bin/sh
[ -f ~/.xprofile ] && . ~/.xprofile
xinput set-prop "Elan Touchpad" "libinput Tapping Enabled" 1
xinput set-prop "Elan Touchpad" "libinput Natural Scrolling Enabled" 1
setxkbmap -layout custom-us-keychron -option caps:escape
xset r rate 200 30
exec i3

I also tried with the export statements directly in the sxrc but they are still not set in the i3 process.
Could you help me see what I'm doing wrong?

Very nice simple program, thanks for making it :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.