mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-23 04:08:27 +03:00
Merge branch 'release/0.1.1'
This commit is contained in:
commit
9dca0468be
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
run: sudo apt-add-repository ppa:mir-team/release
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install libmiral-dev libgtest-dev libyaml-cpp-dev libglib2.0-dev libevdev-dev nlohmann-json3-dev
|
||||
run: sudo apt-get install libmiral-dev libgtest-dev libyaml-cpp-dev libglib2.0-dev libevdev-dev nlohmann-json3-dev libnotify-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
@ -20,6 +20,7 @@ pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(YAML REQUIRED IMPORTED_TARGET yaml-cpp)
|
||||
pkg_check_modules(LIBEVDEV REQUIRED IMPORTED_TARGET libevdev)
|
||||
find_package(nlohmann_json 3.2.0 REQUIRED)
|
||||
pkg_check_modules(LIBNOTIFY REQUIRED IMPORTED_TARGET libnotify)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@ -41,7 +42,8 @@ add_executable(miracle-wm
|
||||
)
|
||||
|
||||
target_include_directories(miracle-wm PUBLIC SYSTEM ${MIRAL_INCLUDE_DIRS})
|
||||
target_link_libraries( miracle-wm ${MIRAL_LDFLAGS} PkgConfig::YAML PkgConfig::GLIB PkgConfig::LIBEVDEV nlohmann_json::nlohmann_json)
|
||||
target_link_libraries( miracle-wm ${MIRAL_LDFLAGS}
|
||||
PkgConfig::YAML PkgConfig::GLIB PkgConfig::LIBEVDEV PkgConfig::LIBNOTIFY nlohmann_json::nlohmann_json)
|
||||
|
||||
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/miracle-wm
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
@ -51,4 +53,13 @@ configure_file(session/usr/local/share/wayland-sessions/miracle-wm-non-snap.desk
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miracle-wm-non-snap.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/wayland-sessions)
|
||||
|
||||
add_custom_target(miracle-wm-sensible-terminal ALL
|
||||
cp ${CMAKE_CURRENT_SOURCE_DIR}/src/miracle-wm-sensible-terminal ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(PROGRAMS
|
||||
src/miracle-wm-sensible-terminal
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
add_subdirectory(tests/)
|
||||
|
@ -106,11 +106,13 @@ With those types defined, the following table defines the allowed key/value pair
|
||||
| inner_gaps | `x: 10, y: 10` | `Vector2` | Size of the gaps in pixels between windows | |
|
||||
| outer_gaps | `x: 10, y: 10` | `Vector2` | Size of the gap between the window group and the edge of the screen in pixels | |
|
||||
| startup_apps | [] | `StartupApp[]` | List of applications to be started when the compositor starts |
|
||||
| terminal | `"miracle-mw-sensible-terminal"` | `String` | The command used when launching a terminal. Defaults to a script that attempts to find a suitable terminal, based on `i3-sensible-terminal` |
|
||||
|
||||
|
||||
## Example
|
||||
```yaml
|
||||
action_key: alt # Set the primary action key to alt
|
||||
terminal: konsole
|
||||
default_action_overrides:
|
||||
- name: terminal # Override the "terminal" keybind to execute with "Ctrl + Shift + Enter"
|
||||
action: down
|
||||
|
@ -30,6 +30,9 @@ apps:
|
||||
# For "reasons" this is being set despite this being a classic snap. This overwrites the nonsense
|
||||
LD_LIBRARY_PATH: ""
|
||||
|
||||
miracle-wm-sensible-terminal:
|
||||
command: usr/local/bin/miracle-wm-sensible-terminal
|
||||
|
||||
parts:
|
||||
miracle-wm:
|
||||
build-attributes:
|
||||
@ -61,6 +64,7 @@ parts:
|
||||
- libevdev-dev
|
||||
- libevdev2
|
||||
- nlohmann-json3-dev
|
||||
- libnotify-dev
|
||||
stage-packages:
|
||||
- libmiral6
|
||||
- mir-graphics-drivers-desktop
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <miral/wayland_extensions.h>
|
||||
#include <miral/display_configuration_option.h>
|
||||
#include <miral/add_init_callback.h>
|
||||
#include <libnotify/notify.h>
|
||||
|
||||
using namespace miral;
|
||||
|
||||
@ -48,6 +49,7 @@ int main(int argc, char const* argv[])
|
||||
auto_restarting_launcher.kill_all();
|
||||
});
|
||||
|
||||
notify_init("miracle-wm");
|
||||
return runner.run_with(
|
||||
{
|
||||
window_managers,
|
||||
|
24
src/miracle-wm-sensible-terminal
Executable file
24
src/miracle-wm-sensible-terminal
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This code is released in public domain by Han Boetes <han@mijncomputer.nl>
|
||||
#
|
||||
# This script tries to exec a terminal emulator by trying some known terminal
|
||||
# emulators.
|
||||
#
|
||||
# We welcome patches that add distribution-specific mechanisms to find the
|
||||
# preferred terminal emulator. On Debian, there is the x-terminal-emulator
|
||||
# symlink for example.
|
||||
#
|
||||
# Invariants:
|
||||
# 1. $TERMINAL must come first
|
||||
# 2. Distribution-specific mechanisms come next, e.g. x-terminal-emulator
|
||||
# 3. The terminal emulator with best accessibility comes first.
|
||||
# 4. No order is guaranteed/desired for the remaining terminal emulators.
|
||||
for terminal in "$TERMINAL" x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty hyper wezterm rio; do
|
||||
if command -v "$terminal" > /dev/null 2>&1; then
|
||||
exec "$terminal" "$@"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
exit 1
|
@ -7,11 +7,21 @@
|
||||
#include <fstream>
|
||||
#include <mir/log.h>
|
||||
#include <libevdev-1.0/libevdev/libevdev.h>
|
||||
#include <fcntl.h>
|
||||
#include <libnotify/notify.h>
|
||||
#include <sys/inotify.h>
|
||||
|
||||
using namespace miracle;
|
||||
|
||||
namespace
|
||||
{
|
||||
int program_exists(std::string const& name)
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "command -v " << name << " > /dev/null 2>&1";
|
||||
return !system(out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
MiracleConfig::MiracleConfig(miral::MirRunner& runner)
|
||||
: runner{runner}
|
||||
{
|
||||
@ -515,6 +525,17 @@ void MiracleConfig::_load()
|
||||
startup_apps.push_back({std::move(command), restart_on_death});
|
||||
}
|
||||
}
|
||||
|
||||
if (config["terminal"])
|
||||
{
|
||||
terminal = config["terminal"].as<std::string>();
|
||||
}
|
||||
|
||||
if (terminal && !program_exists(terminal.value()))
|
||||
{
|
||||
desired_terminal = terminal.value();
|
||||
terminal.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void MiracleConfig::_watch(miral::MirRunner& runner)
|
||||
@ -694,4 +715,21 @@ void MiracleConfig::unregister_listener(int handle)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::optional<std::string> const& MiracleConfig::get_terminal_command() const
|
||||
{
|
||||
if (!terminal)
|
||||
{
|
||||
auto error_string = "Terminal program does not exist " + desired_terminal;
|
||||
mir::log_error("%s", error_string.c_str());
|
||||
NotifyNotification* n = notify_notification_new(
|
||||
"Terminal program does not exist",
|
||||
error_string.c_str(),
|
||||
nullptr);
|
||||
notify_notification_set_timeout(n, 5000);
|
||||
notify_notification_show(n, nullptr);
|
||||
}
|
||||
return terminal;
|
||||
}
|
@ -9,13 +9,13 @@
|
||||
#include <mir/fd.h>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
namespace miral
|
||||
{
|
||||
class MirRunner;
|
||||
class FdHandle;
|
||||
}
|
||||
|
||||
namespace miracle
|
||||
{
|
||||
|
||||
@ -92,6 +92,7 @@ public:
|
||||
[[nodiscard]] int get_outer_gaps_x() const;
|
||||
[[nodiscard]] int get_outer_gaps_y() const;
|
||||
[[nodiscard]] std::vector<StartupApp> const& get_startup_apps() const;
|
||||
[[nodiscard]] std::optional<std::string> const& get_terminal_command() const;
|
||||
|
||||
/// Register a listener on configuration change. A lower "priority" number signifies that the
|
||||
/// listener should be triggered earlier. A higher priority means later
|
||||
@ -128,7 +129,8 @@ private:
|
||||
int outer_gaps_x = 10;
|
||||
int outer_gaps_y = 10;
|
||||
std::vector<StartupApp> startup_apps;
|
||||
|
||||
std::optional<std::string> terminal = "miracle-wm-sensible-terminal";
|
||||
std::string desired_terminal = "";
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,39 +25,6 @@ const int MODIFIER_MASK =
|
||||
mir_input_event_modifier_sym |
|
||||
mir_input_event_modifier_ctrl |
|
||||
mir_input_event_modifier_meta;
|
||||
|
||||
// Note: This list was taken from i3: https://github.com/i3/i3/blob/next/i3-sensible-terminal
|
||||
// We will want this to be configurable in the future.
|
||||
const std::string POSSIBLE_TERMINALS[] = {
|
||||
"x-terminal-emulator",
|
||||
"mate-terminal",
|
||||
"gnome-terminal",
|
||||
"terminator",
|
||||
"xfce4-terminal",
|
||||
"urxvt", "rxvt",
|
||||
"termit",
|
||||
"Eterm",
|
||||
"aterm",
|
||||
"uxterm",
|
||||
"xterm",
|
||||
"roxterm",
|
||||
"termite",
|
||||
"lxterminal",
|
||||
"terminology",
|
||||
"st",
|
||||
"qterminal",
|
||||
"lilyterm",
|
||||
"tilix",
|
||||
"terminix",
|
||||
"konsole",
|
||||
"kitty",
|
||||
"guake",
|
||||
"tilda",
|
||||
"alacritty",
|
||||
"hyper",
|
||||
"wezterm",
|
||||
"rio"
|
||||
};
|
||||
}
|
||||
|
||||
TilingWindowManagementPolicy::TilingWindowManagementPolicy(
|
||||
@ -109,12 +76,12 @@ bool TilingWindowManagementPolicy::handle_keyboard_event(MirKeyboardEvent const*
|
||||
switch (key_command)
|
||||
{
|
||||
case Terminal:
|
||||
for (auto const& terminal : POSSIBLE_TERMINALS)
|
||||
{
|
||||
if (external_client_launcher.launch({terminal}) > 0)
|
||||
break;
|
||||
}
|
||||
{
|
||||
auto terminal_command = config->get_terminal_command();
|
||||
if (terminal_command)
|
||||
external_client_launcher.launch({terminal_command.value()});
|
||||
return true;
|
||||
}
|
||||
case RequestVertical:
|
||||
if(active_output) active_output->get_active_tree().request_vertical();
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user