From e32ec4df774c37237f0aae33a42e00cdbb138491 Mon Sep 17 00:00:00 2001 From: Lakindu Akash Date: Thu, 27 Aug 2020 03:47:29 +0530 Subject: [PATCH] Fix paths for wihotspot_gui --- src/CMakeLists.txt | 14 +++++++++++--- src/desktop/wifihotspot.desktop | 2 +- src/scripts/Makefile | 4 +++- src/scripts/wihotspot | 4 ++++ src/ui/h_prop.c | 4 +++- src/ui/ui.c | 4 ++-- 6 files changed, 24 insertions(+), 8 deletions(-) create mode 100755 src/scripts/wihotspot diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5c6ba3..e55815c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.12) -project(wihotspot) +project(wihotspot_gui) include(FindPkgConfig) pkg_check_modules(GTK gtk+-3.0 REQUIRED) @@ -10,7 +10,7 @@ include_directories(${X11_INCLUDE_DIRS}) set(CMAKE_C_STANDARD 99) set (CMAKE_CXX_STANDARD 11) -add_executable(wihotspot ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h) +add_executable(wihotspot_gui ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h) target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES}) @@ -42,12 +42,20 @@ add_custom_target(install_build COMMAND install -Dm644 ${CMAKE_SOURCE_DIR}/desktop/wifihotspot.desktop $ENV{DESTDIR}${appdir}/applications/${PROJECT_NAME}.desktop DEPENDS ${PROJECT_NAME} COMMENT Installing files... + + COMMENT Remove old files if exist + COMMAND rm -rf $ENV{DESTDIR}${appdir}/wihotspot + COMMAND rm -f $ENV{DESTDIR}${appdir}/applications/wihotspot.desktop ) add_custom_target(uninstall_build COMMAND rm -rf $ENV{DESTDIR}${appdir}/${PROJECT_NAME} COMMAND rm -f $ENV{DESTDIR}${appbin}/${PROJECT_NAME} COMMAND rm -f $ENV{DESTDIR}${appdir}/applications/${PROJECT_NAME}.desktop - COMMAND rm -f $ENV{DESTDIR}${appdir}/${PROJECT_NAME}/${PROJECT_NAME}.desktop + COMMAND rm -rf $ENV{DESTDIR}${appdir}/${PROJECT_NAME} COMMENT Unstalling files... + + COMMENT Remove old files if exist + COMMAND rm -rf $ENV{DESTDIR}${appdir}/wihotspot + COMMAND rm -f $ENV{DESTDIR}${appdir}/applications/wihotspot.desktop ) \ No newline at end of file diff --git a/src/desktop/wifihotspot.desktop b/src/desktop/wifihotspot.desktop index e21f50a..2a2c830 100644 --- a/src/desktop/wifihotspot.desktop +++ b/src/desktop/wifihotspot.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=WifiHotspot -Icon=/usr/share/wihotspot/hotspot.png +Icon=/usr/share/wihotspot_gui/hotspot.png Exec=sh -c 'env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot' Terminal=false Categories=System diff --git a/src/scripts/Makefile b/src/scripts/Makefile index 63ae1b3..a113e21 100644 --- a/src/scripts/Makefile +++ b/src/scripts/Makefile @@ -12,6 +12,7 @@ install: [ ! -d /lib/systemd/system ] || install -CDm644 create_ap.service $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service install -CDm644 bash_completion $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap install -CDm644 README.md $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md + install -CDm755 wihotspot $(DESTDIR)$(BINDIR)/wihotspot uninstall: rm -f $(DESTDIR)$(BINDIR)/create_ap @@ -19,4 +20,5 @@ uninstall: [ ! -f /lib/systemd/system/create_ap.service ] || rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap rm -f $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md - rm -f /etc/sudoers.d/create_ap + rm -f /etc/sudoers.d/create_ap # For older versions + rm -f $(DESTDIR)$(BINDIR)/wihotspot diff --git a/src/scripts/wihotspot b/src/scripts/wihotspot new file mode 100755 index 0000000..e6860eb --- /dev/null +++ b/src/scripts/wihotspot @@ -0,0 +1,4 @@ +#!/bin/sh + +# Start wihotspot_gui as root user +pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot_gui diff --git a/src/ui/h_prop.c b/src/ui/h_prop.c index c007784..1f1ec6f 100644 --- a/src/ui/h_prop.c +++ b/src/ui/h_prop.c @@ -184,7 +184,9 @@ const char* build_kill_create_ap_command(char* pid){ static int init_get_running(){ - const char* cmd="sudo create_ap --list-running"; + char cmd[BUFSIZE]; + snprintf(cmd, BUFSIZE, "%s %s --list-running",SUDO, CREATE_AP); + FILE *fp; if ((fp = popen(cmd, "r")) == NULL) { diff --git a/src/ui/ui.c b/src/ui/ui.c index 66ae64a..2d6bde0 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -148,7 +148,7 @@ static void loadStyles(){ const char *style_file; const char* debug_style_file="glade/style.css"; - const char* prod_style_file="/usr/share/wihotspot/glade/style.css"; + const char* prod_style_file="/usr/share/wihotspot_gui/glade/style.css"; FILE *file; @@ -348,7 +348,7 @@ int initUi(int argc, char *argv[]){ // } const char* debug_glade_file="glade/wifih.ui"; - const char* prod_glade_file="/usr/share/wihotspot/glade/wifih.ui"; + const char* prod_glade_file="/usr/share/wihotspot_gui/glade/wifih.ui"; FILE *file; builder = gtk_builder_new();