diff --git a/Cargo.lock b/Cargo.lock index d3ce65a..7e36ad9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,8 @@ dependencies = [ "serde_default", "serde_yml", "socks", + "winapi", + "winresource", ] [[package]] @@ -1647,6 +1649,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winresource" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4a67c78ee5782c0c1cb41bebc7e12c6e79644daa1650ebbc1de5d5b08593f7" +dependencies = [ + "toml", + "version_check", +] + [[package]] name = "wit-bindgen-rt" version = "0.33.0" diff --git a/Cargo.toml b/Cargo.toml index ca0b740..5750717 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,12 @@ serde_default = "0.2.0" socks = "0.3.4" libnotify = { version = "1.0.3", optional = true } gdk-pixbuf = { version = "0.3.0", optional = true } +winapi = { version = "0.3.9", optional = true, features = ["wincon", "winuser"] } [features] -default = ["libnotify"] +default = [] libnotify = ["dep:libnotify", "dep:gdk-pixbuf"] +winapi = ["dep:winapi"] + +[build-dependencies] +winresource = "0.1.20" diff --git a/Makefile b/Makefile index a393033..0bdb9bb 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ build: build/windows-x86_64 build/linux-x86_64 build/windows-x86_64: mkdir -p build mkdir -p $@ - cargo build -r --target x86_64-pc-windows-gnu + cargo build -r -F winapi --target x86_64-pc-windows-gnu curl -s https://api.github.com/repos/wingtk/gvsbuild/releases/latest \ | grep -o ".*browser_download_url.*GTK4_Gvsbuild.*_x64.zip.*" \ | cut -d : -f 2,3 \ @@ -16,17 +16,17 @@ build/windows-x86_64: mv $@/bin/* $@/ cp target/x86_64-pc-windows-gnu/release/bRAC.exe $@ rm -r $@/bin - # TODO: disable console - # TODO: set icon build/linux-x86_64: mkdir -p build mkdir -p $@ - cargo build -r --target x86_64-unknown-linux-gnu + cargo build -r -F libnotify --target x86_64-unknown-linux-gnu # patchbin target/x86_64-unknown-linux-gnu/release/bRAC cp target/x86_64-unknown-linux-gnu/release/bRAC $@ - cp bRAC.png $@ - cp bRAC.desktop $@ + cp ru.themixray.bRAC.png $@ + cp ru.themixray.bRAC.desktop $@ + cp install.sh $@ + cp uninstall.sh $@ clean: rm -r build \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..076705b --- /dev/null +++ b/build.rs @@ -0,0 +1,16 @@ +use { + std::{ + env, + io, + }, + winresource::WindowsResource, +}; + +fn main() -> io::Result<()> { + if env::var_os("CARGO_CFG_WINDOWS").is_some() { + WindowsResource::new() + .set_icon("icon.ico") + .compile()?; + } + Ok(()) +} \ No newline at end of file diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..f45e063 Binary files /dev/null and b/icon.ico differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..0854c32 --- /dev/null +++ b/install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +if [ ! -f bRAC ]; then + if cargo build -r; then + cp target/release/bRAC . + else + echo "There is no bRAC binary" + exit 1 + fi +fi + +cp bRAC /bin/bRAC +chmod +x /bin/bRAC +cp ru.themixray.bRAC.png /usr/share/pixmaps +cp ru.themixray.bRAC.desktop /usr/share/applications \ No newline at end of file diff --git a/bRAC.desktop b/ru.themixray.bRAC.desktop similarity index 88% rename from bRAC.desktop rename to ru.themixray.bRAC.desktop index 80f4ad5..c1898a7 100644 --- a/bRAC.desktop +++ b/ru.themixray.bRAC.desktop @@ -3,7 +3,7 @@ Name=bRAC Version=0.1.4 Type=Application Comment=better RAC client -Icon=bRAC.png +Icon=ru.themixray.bRAC.png Exec=bRAC Categories=Network; StartupNotify=true diff --git a/bRAC.png b/ru.themixray.bRAC.png similarity index 100% rename from bRAC.png rename to ru.themixray.bRAC.png diff --git a/src/chat/gui.rs b/src/chat/gui.rs index d8ef55b..58bee08 100644 --- a/src/chat/gui.rs +++ b/src/chat/gui.rs @@ -32,7 +32,7 @@ ctx::Context, on_send_message, parse_message, print_message, recv_tick, sanitize struct UiModel { chat_box: GtkBox, chat_scrolled: ScrolledWindow, - // app: Application, + app: Application, window: ApplicationWindow, #[cfg(feature = "libnotify")] notifications: Arc>> @@ -589,7 +589,7 @@ fn build_ui(ctx: Arc, app: &Application) -> UiModel { UiModel { chat_scrolled, chat_box, - // app: app.clone(), + app: app.clone(), window: window.clone(), #[cfg(feature = "libnotify")] notifications: Arc::new(RwLock::new(Vec::::new())) @@ -689,7 +689,7 @@ fn send_notification(_: Arc, ui: &UiModel, title: &str, message: &str) } #[cfg(not(feature = "libnotify"))] -fn send_notification(ctx: Arc, ui: &UiModel, title: &str, message: &str) { +fn send_notification(_: Arc, ui: &UiModel, title: &str, message: &str) { use gtk4::gio::Notification; let notif = Notification::new(title); diff --git a/src/main.rs b/src/main.rs index 0bd0816..82f170d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,12 @@ use std::sync::Arc; use bRAC::proto::{connect, read_messages, send_message}; use bRAC::chat::{config::{get_config_path, load_config, Args}, ctx::Context, run_main_loop}; -use clap::Parser; - +use clap::Parser; fn main() { + #[cfg(feature = "winapi")] + unsafe { winapi::um::wincon::FreeConsole() }; + let args = Args::parse(); let config_path = get_config_path(); diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..34a9fb8 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +getent passwd | while IFS=: read -r name password uid gid gecos home shell; do + rm -rf $home/.config/bRAC; +done + +rm -f /bin/bRAC +rm -f ru.themixray.bRAC.png /usr/share/pixmaps +rm -f ru.themixray.bRAC.desktop /usr/share/applications \ No newline at end of file