mirror of https://github.com/fairyglade/ly.git
Added wayland session supports
This commit is contained in:
parent
10bd01aaeb
commit
a2cf64e84a
1
makefile
1
makefile
|
|
@ -61,6 +61,7 @@ install:$(BIND)/$(NAME)
|
|||
install -dZ ${DESTDIR}/etc/ly
|
||||
install -DZ $(BIND)/$(NAME) -t ${DESTDIR}/usr/bin
|
||||
install -DZ xsetup.sh -t ${DESTDIR}/etc/ly
|
||||
install -DZ wsetup.sh -t ${DESTDIR}/etc/ly
|
||||
install -DZ $(RESD)/config.ini -t ${DESTDIR}/etc/ly
|
||||
install -dZ ${DESTDIR}/etc/ly/lang
|
||||
install -DZ $(RESD)/lang/* -t ${DESTDIR}/etc/ly/lang
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
#xauthority=.lyxauth
|
||||
#path=/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/env
|
||||
|
||||
#wayland_cmd=/etc/ly/wsetup.sh
|
||||
#wayland_sessions=/usr/share/wayland-sessions
|
||||
|
||||
# shutdown is given parameters, do not use an alternative
|
||||
# this is here only to allow you to change its location
|
||||
#shutdown_cmd=/sbin/shutdown
|
||||
|
|
|
|||
28
src/config.c
28
src/config.c
|
|
@ -65,6 +65,10 @@ int config_lang_handler(void* user, const char* section, const char* name, const
|
|||
{
|
||||
cfg_dup(&lang.xinitrc, value);
|
||||
}
|
||||
else if (strcmp(name, "wayland") == 0)
|
||||
{
|
||||
cfg_dup(&lang.wayland, value);
|
||||
}
|
||||
else if (strcmp(name, "logout") == 0)
|
||||
{
|
||||
cfg_dup(&lang.logout, value);
|
||||
|
|
@ -184,6 +188,10 @@ void config_lang_patch()
|
|||
{
|
||||
lang.xinitrc = strdup("xinitrc");
|
||||
}
|
||||
if (lang.wayland == 0)
|
||||
{
|
||||
lang.wayland = strdup("wayland");
|
||||
}
|
||||
if (lang.logout == 0)
|
||||
{
|
||||
lang.logout = strdup("logout");
|
||||
|
|
@ -282,6 +290,7 @@ void config_lang_free()
|
|||
free(lang.f2);
|
||||
free(lang.shell);
|
||||
free(lang.xinitrc);
|
||||
free(lang.wayland);
|
||||
free(lang.logout);
|
||||
free(lang.capslock);
|
||||
free(lang.numlock);
|
||||
|
|
@ -376,6 +385,14 @@ int config_config_handler(void* user, const char* section, const char* name, con
|
|||
{
|
||||
cfg_dup(&config.x_cmd_setup, value);
|
||||
}
|
||||
else if (strcmp(name, "wayland_sessions") == 0)
|
||||
{
|
||||
cfg_dup(&config.wayland_sessions, value);
|
||||
}
|
||||
else if (strcmp(name, "wayland_cmd") == 0)
|
||||
{
|
||||
cfg_dup(&config.wayland_cmd, value);
|
||||
}
|
||||
else if (strcmp(name, "mcookie_cmd") == 0)
|
||||
{
|
||||
cfg_dup(&config.mcookie_cmd, value);
|
||||
|
|
@ -519,7 +536,14 @@ void config_config_patch()
|
|||
{
|
||||
config.x_cmd_setup = strdup("/etc/ly/xsetup.sh");
|
||||
}
|
||||
if (config.mcookie_cmd == 0)
|
||||
if (config.wayland_sessions == 0){
|
||||
config.wayland_sessions = strdup("/usr/share/wayland-sessions");
|
||||
}
|
||||
if (config.wayland_cmd == 0)
|
||||
{
|
||||
config.wayland_cmd = strdup("/etc/ly/wsetup.sh");
|
||||
}
|
||||
if (config.mcookie_cmd == 0)
|
||||
{
|
||||
config.mcookie_cmd = strdup("/usr/bin/mcookie");
|
||||
}
|
||||
|
|
@ -569,6 +593,8 @@ void config_config_free()
|
|||
{
|
||||
free(config.xsessions);
|
||||
free(config.service_name);
|
||||
free(config.wayland_sessions);
|
||||
free(config.wayland_cmd);
|
||||
free(config.x_cmd);
|
||||
free(config.x_cmd_setup);
|
||||
free(config.mcookie_cmd);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ struct lang
|
|||
char* capslock;
|
||||
char* numlock;
|
||||
|
||||
char* wayland;
|
||||
|
||||
// errors
|
||||
char* err_pam_buf;
|
||||
char* err_pam_sys;
|
||||
|
|
@ -65,6 +67,10 @@ struct config
|
|||
char* service_name;
|
||||
char* x_cmd;
|
||||
char* x_cmd_setup;
|
||||
|
||||
char* wayland_sessions;
|
||||
char* wayland_cmd;
|
||||
|
||||
char* mcookie_cmd;
|
||||
char* xauthority;
|
||||
char* path;
|
||||
|
|
|
|||
172
src/desktop.c
172
src/desktop.c
|
|
@ -9,82 +9,130 @@
|
|||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
|
||||
char* value_name = NULL;
|
||||
char* value_exec = NULL;
|
||||
char *value_name = NULL;
|
||||
char *value_exec = NULL;
|
||||
|
||||
int desktop_handler(void* user, const char* section, const char* name, const char* value)
|
||||
{
|
||||
(void)(user);
|
||||
int desktop_handler(void *user, const char *section, const char *name, const char *value) {
|
||||
(void) (user);
|
||||
|
||||
if (strcmp(section, "Desktop Entry") == 0)
|
||||
{
|
||||
if ((strcmp(name, "Name") == 0) && (value_name == NULL))
|
||||
{
|
||||
value_name = strdup(value);
|
||||
}
|
||||
if ((strcmp(name, "Exec") == 0) && (value_exec == NULL))
|
||||
{
|
||||
value_exec = strdup(value);
|
||||
}
|
||||
}
|
||||
if (strcmp(section, "Desktop Entry") == 0) {
|
||||
if ((strcmp(name, "Name") == 0) && (value_name == NULL)) {
|
||||
value_name = strdup(value);
|
||||
}
|
||||
if ((strcmp(name, "Exec") == 0) && (value_exec == NULL)) {
|
||||
value_exec = strdup(value);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum err desktop_load(struct desktop* target)
|
||||
{
|
||||
DIR* dir;
|
||||
struct dirent* dir_info;
|
||||
enum err desktop_load_wayland_sessions(struct desktop *target) {
|
||||
DIR *dir;
|
||||
struct dirent *dir_info;
|
||||
|
||||
#if defined(NAME_MAX)
|
||||
char path[NAME_MAX];
|
||||
#elif defined(_POSIX_PATH_MAX)
|
||||
char path[_POSIX_PATH_MAX];
|
||||
#else
|
||||
char path[1024];
|
||||
#endif
|
||||
#if defined(NAME_MAX)
|
||||
char path[NAME_MAX];
|
||||
#elif defined(_POSIX_PATH_MAX)
|
||||
char path[_POSIX_PATH_MAX];
|
||||
#else
|
||||
char path[1024];
|
||||
#endif
|
||||
|
||||
// checks dir existence
|
||||
if (access(config.xsessions, F_OK) == -1)
|
||||
{
|
||||
return XSESSIONS_MISSING;
|
||||
}
|
||||
// checks dir existence
|
||||
if (access(config.wayland_sessions, F_OK) == -1) {
|
||||
return XSESSIONS_MISSING;
|
||||
}
|
||||
|
||||
// requests read access
|
||||
dir = opendir(config.xsessions);
|
||||
// requests read access
|
||||
dir = opendir(config.wayland_sessions);
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
return XSESSIONS_READ;
|
||||
}
|
||||
if (dir == NULL) {
|
||||
return XSESSIONS_READ;
|
||||
}
|
||||
|
||||
// reads the content
|
||||
dir_info = readdir(dir);
|
||||
// reads the content
|
||||
dir_info = readdir(dir);
|
||||
|
||||
while (dir_info != NULL)
|
||||
{
|
||||
// skips the files starting with "."
|
||||
if ((dir_info->d_name)[0] == '.')
|
||||
{
|
||||
dir_info = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
while (dir_info != NULL) {
|
||||
// skips the files starting with "."
|
||||
if ((dir_info->d_name)[0] == '.') {
|
||||
dir_info = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(path, (sizeof (path)) - 1, "%s/", config.xsessions);
|
||||
strncat(path, dir_info->d_name, (sizeof (path)) - 1);
|
||||
ini_parse(path, desktop_handler, NULL);
|
||||
snprintf(path, (sizeof(path)) - 1, "%s/", config.wayland_sessions);
|
||||
strncat(path, dir_info->d_name, (sizeof(path)) - 1);
|
||||
ini_parse(path, desktop_handler, NULL);
|
||||
|
||||
if ((value_name != NULL) && (value_exec != NULL))
|
||||
{
|
||||
widget_desktop_add(target, value_name, value_exec, DS_XORG);
|
||||
value_name = NULL;
|
||||
value_exec = NULL;
|
||||
}
|
||||
if ((value_name != NULL) && (value_exec != NULL)) {
|
||||
widget_desktop_add(target, value_name, value_exec, DS_WAYLAND);
|
||||
value_name = NULL;
|
||||
value_exec = NULL;
|
||||
}
|
||||
|
||||
dir_info = readdir(dir);
|
||||
}
|
||||
dir_info = readdir(dir);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
closedir(dir);
|
||||
|
||||
return OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum err desktop_load_xorg_sessions(struct desktop *target) {
|
||||
DIR *dir;
|
||||
struct dirent *dir_info;
|
||||
|
||||
#if defined(NAME_MAX)
|
||||
char path[NAME_MAX];
|
||||
#elif defined(_POSIX_PATH_MAX)
|
||||
char path[_POSIX_PATH_MAX];
|
||||
#else
|
||||
char path[1024];
|
||||
#endif
|
||||
|
||||
// checks dir existence
|
||||
if (access(config.xsessions, F_OK) == -1) {
|
||||
return XSESSIONS_MISSING;
|
||||
}
|
||||
|
||||
// requests read access
|
||||
dir = opendir(config.xsessions);
|
||||
|
||||
if (dir == NULL) {
|
||||
return XSESSIONS_READ;
|
||||
}
|
||||
|
||||
// reads the content
|
||||
dir_info = readdir(dir);
|
||||
|
||||
while (dir_info != NULL) {
|
||||
// skips the files starting with "."
|
||||
if ((dir_info->d_name)[0] == '.') {
|
||||
dir_info = readdir(dir);
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(path, (sizeof(path)) - 1, "%s/", config.xsessions);
|
||||
strncat(path, dir_info->d_name, (sizeof(path)) - 1);
|
||||
ini_parse(path, desktop_handler, NULL);
|
||||
|
||||
if ((value_name != NULL) && (value_exec != NULL)) {
|
||||
widget_desktop_add(target, value_name, value_exec, DS_XORG);
|
||||
value_name = NULL;
|
||||
value_exec = NULL;
|
||||
}
|
||||
|
||||
dir_info = readdir(dir);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum err desktop_load(struct desktop* target){
|
||||
int xload = desktop_load_xorg_sessions(target);
|
||||
int wload = desktop_load_wayland_sessions(target);
|
||||
return xload != OK ? xload : wload != OK ? wload : OK;
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ void launch_wayland(struct passwd* pwd, pam_handle_t* pam_handle,
|
|||
const char* de_command)
|
||||
{
|
||||
char cmd[32];
|
||||
snprintf(cmd, 32, "exec %s", de_command);
|
||||
snprintf(cmd, 32, "exec %s %s", config.wayland_cmd, de_command);
|
||||
reset_terminal(pwd);
|
||||
execl(pwd->pw_shell, pwd->pw_shell, "-l", "-c", cmd, NULL);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ enum err widget_desktop(struct desktop* target)
|
|||
|
||||
error |= widget_desktop_add(target, strdup(lang.shell), strdup(""), DS_SHELL);
|
||||
error |= widget_desktop_add(target, strdup(lang.xinitrc), strdup(""), DS_XINITRC);
|
||||
error |= widget_desktop_add(target, strdup(lang.wayland), strdup(""), DS_WAYLAND);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
# wayland-session - run as user
|
||||
# Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
||||
# This file is extracted from kde-workspace (kdm/kfrontend/genkdmconf.c)
|
||||
# Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>
|
||||
session=$1
|
||||
# Note that the respective logout scripts are not sourced.
|
||||
case $SHELL in
|
||||
*/bash)
|
||||
[ -z "$BASH" ] && exec $SHELL $0 "$@"
|
||||
set +o posix
|
||||
[ -f /etc/profile ] && . /etc/profile
|
||||
if [ -f $HOME/.bash_profile ]; then
|
||||
. $HOME/.bash_profile
|
||||
elif [ -f $HOME/.bash_login ]; then
|
||||
. $HOME/.bash_login
|
||||
elif [ -f $HOME/.profile ]; then
|
||||
. $HOME/.profile
|
||||
fi
|
||||
;;
|
||||
*/zsh)
|
||||
[ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
|
||||
[ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc
|
||||
zhome=${ZDOTDIR:-$HOME}
|
||||
# zshenv is always sourced automatically.
|
||||
[ -f $zdir/zprofile ] && . $zdir/zprofile
|
||||
[ -f $zhome/.zprofile ] && . $zhome/.zprofile
|
||||
[ -f $zdir/zlogin ] && . $zdir/zlogin
|
||||
[ -f $zhome/.zlogin ] && . $zhome/.zlogin
|
||||
emulate -R sh
|
||||
;;
|
||||
*/csh|*/tcsh)
|
||||
# [t]cshrc is always sourced automatically.
|
||||
# Note that sourcing csh.login after .cshrc is non-standard.
|
||||
wlsess_tmp=${mktemp /tmp/wlsess-env-XXXXXX}
|
||||
$SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $wlsess_tmp"
|
||||
. $wlsess_tmp
|
||||
rm -f $wlsess_tmp
|
||||
;;
|
||||
*) # Plain sh, ksh, and anything we do not know.
|
||||
[ -f /etc/profile ] && . /etc/profile
|
||||
[ -f $HOME/.profile ] && . $HOME/.profile
|
||||
;;
|
||||
esac
|
||||
eval exec "$session"
|
||||
Loading…
Reference in New Issue