#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ubl-strings.h" #define VTE_INCLUDE #include #include #include #ifndef UBL_SETINGS_VIDEO_H #define UBL_SETINGS_VIDEO_H #define WIKI_LINK " https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-video" #define HOMEPAGE_LINK _("https://wiki.ublinux.com") #define icon_name "com.ublinux.ubl-settings-video" #define banner_path "/com/ublinux/images/ubl-settings-video-banner.png" #define glade_path "/com/ublinux/ui/ubl-settings-video.glade" #define glade_path_monitor "/com/ublinux/ui/ubl-settings-video-monitor.glade" #define glade_path_configuration "/com/ublinux/ui/ubl-settings-video-configuration.glade" #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-video" #define CssPath "/com/ublinux/css/ubl-settings-video.css" #define StatusLoadGlobalFailed _("Failed to load global configuration") #define StatusLoadLocalFailed _("Failed to load local configuration") #define StatusSaveGlobalFailed _("Saving to global configuration Succeeded") #define StatusSaveLocalFailed _("Saving to local configuration Succeeded") #define get_ports_command "xrandr |grep -E \"*connected\" |cut -d' ' -f1" #define get_resolutions_command "xrandr |grep -noP \"\\d+x+\\d+\"" #define get_resolution_ports_command "xrandr |grep -nwP \"connected\" |grep -oE \"[-0-9a-zA-Z:]{1,} connected\" |grep -oE \"[-0-9a-zA-Z:]{1,} \"" #define get_proprietary_drivers_info_path "/usr/share/ubl-settings-video/csv/video-drivers.csv" #define get_resolutions_supportable_command "/usr/share/ubl-settings-video/csv/resolutions.csv" #define get_frequences_command "xrandr |grep -v -n \"[a-z][a-z]\" |sed 's/ * / /g' |cut -d' ' -f1,3-" #define load_drivers_command "/usr/bin/ubconfig --default --source " #define load_drivers_global_command "/usr/bin/ubconfig --default --source global get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN VGADRV_AUTO " #define save_drivers_global_command "/usr/bin/ubconfig --target global --noexecute set video " #define save_drivers_global_local_command "/usr/bin/ubconfig set video " #define load_drivers_local_command "/usr/bin/ubconfig --default --source system get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN VGADRV_AUTO " #define save_drivers_local_command "/usr/bin/ubconfig --target system set video " #define remove_drivers_global_command "/usr/bin/ubconfig --target system remove video " #define remove_drivers_local_command "/usr/bin/ubconfig --target system remove video " #define install_proprietary_command(target) yon_char_append("pacman --quiet --needed --noconfirm -Sy ",target) #define delete_proprietary_command(target) yon_char_append("pacman -R --noconfirm ",target) #define get_info_proprietary_command(target) yon_char_append("pamac-manager --details=",target) #define get_version_proprietary_command "grep \"VERSION_ID=\" /etc/os-release | cut -d= -f2" #define yon_check_database_command "pacman -Sqs >/dev/null" #define yon_get_kernels_installed "find /usr/lib/modules/ -maxdepth 2 -type f -iname \"pkgbase\" -exec cat {} + 2>/dev/null" #define yon_get_is_installed_command(target) yon_char_append("pacman -Qs ",target) #define yon_get_is_exist_command(target) yon_char_append("pacman -Ss ",target) #define get_proprietary_drivers_command "pacman -Sysq 'ubm-nvidia-.*|amdgpu|^nvidia-[0-9]{1,}[a-zA-Z]{0,}-dkms|^mesa$|^xf86-video-intel$|^lib32-vulkan-intel$'" #define get_proprietary_drivers_local_command "pacman -Qq |grep -E 'nvidia|^vulkan-amdgpu|^amdgpu-pro-libgl'" // #define get_proprietary_drivers_command "LC_ALL=C pacman -Ss ubm-nvidia-.* |grep -oE \"[a-zA-Z-]{1,}nvidia-[a-zA-Z0-9-]{1,}|installed\"|sed ':a;N;$!ba;s/\\ninstalled/ installed/g'" #define get_adapter_info "lshw -c display -quiet |grep -oE \"vendor:[0-9a-zA-Z ]{1,}|description:[0-9a-zA-Z ]{1,}|product:[]0-9a-zA-Z [-]{1,}\"|sed 's/: /=/g';lspci | grep -E ' VGA | Display ' | cut -d\" \" -f 1 | xargs -i lspci -v -s {} |grep -oE \"Kernel[:a-zA-Z0-9: ,_]{1,}\"|sed 's/: /=/g'|sed 's/ /-/g'" #define get_adapter_info_json "lshw -c display -quiet -json" #define get_drivers_for_card_command "lspci | grep -E ' VGA | Display ' | cut -d' ' -f 1 | xargs -i lspci -k -s {}|grep Kernel|sed -e 's/^\t*//g' -e 's/Kernel driver in use: /uses=/g' -e 's/Kernel modules: /all=/g'" #define XORG_MONITOR(port) yon_char_append("XORG_MONITOR[",yon_char_append(port,"]")) #define VGADRV_AUTO "VGADRV_AUTO" #define VGADRV_NOFREE "VGADRV_NOFREE" #define XORG_EXT "XORG_EXT" #define XORG_DPI "XORG_DPI" #define FAILSAFEATI "FAILSAFEATI" #define FAILSAFENVIDIA "FAILSAFENVIDIA" #define OPTIRUN "OPTIRUN" #define PRIMUSRUN "PRIMUSRUN" #define INTEGRATEDVGA "INTEGRATEDVGA" #define KWIN_TRIPLE_BUFFER "export KWIN_TRIPLE_BUFFER" #define GL_YIELD "export __GL_YIELD" #define VGADRV_AUTO_command "ubconfig --source global get [video] VGADRV_AUTO" #define VGADRV_NOFREE_command "ubconfig --source global get [video] VGADRV_NOFREE" #define XORG_EXT_command "ubconfig --source global get [video] XORG_EXT" #define XORG_DPI_command "ubconfig --source global get [video] XORG_DPI" #define FAILSAFEATI_command "ubconfig --source global get [video] FAILSAFEATI" #define FAILSAFENVIDIA_command "ubconfig --source global get [video] FAILSAFENVIDIA" #define OPTIRUN_command "ubconfig --source global get [video] OPTIRUN" #define PRIMUSRUN_command "ubconfig --source global get [video] PRIMUSRUN" #define INTEGRATEDVGA_command "ubconfig --source global get [video] INTEGRATEDVGA" #define KWIN_TRIPLE_BUFFER_command "ubconfig --source global get [/etc/profile.d/ublinux.sh] KWIN_TRIPLE_BUFFER" #define GL_YIELD_command "ubconfig --source global get [/etc/profile.d/ublinux.sh] __GL_YIELD" #define XORG_PARAMETER "XORG_MONITOR" #define config_get_command(source) yon_char_unite("ubconfig --source ",source," get [video] XORG_MONITOR[*] VGADRV_AUTO VGADRV_NOFREE XORG_EXT XORG_DPI FAILSAFEATI FAILSAFENVIDIA OPTIRUN PRIMUSRUN INTEGRATEDVGA",NULL) #define config_get_default_command "" #define config_get_global_only_parameters "" #define config_get_local_only_parameters "" #define XORG_MONITOR_get_command "ubconfig --source global get [video] XORG_MONITOR[*]" char *drivers_always_active[] = {"lib32-vulkan-intel","xf86-video-intel"}; int drivers_always_active_size = 3; typedef struct{ char* command; void *data; } thread_input; char *local; typedef char *string; string version_application; #define _(String) gettext(String) typedef dictionary* monitor_config; typedef dictionary* proprietary_config; typedef dictionary* monitor_view; typedef struct { config_str line; int size; } resolution_supported; typedef struct { template_window_fields GtkWidget *AutoDriverCombo; GtkWidget *FreeDriverCombo; GtkWidget *FailsafeNvidiaCombo; GtkWidget *FailsafeAMDCombo; GtkWidget *MonitorsBox; GtkWidget *DontSwitchDisplaysOffCombo; GtkWidget *DisplayScalingCombo; GtkWidget *DisplayDiscreteOnly; GtkWidget *OptirunCombo; GtkWidget *OptirunEntry; GtkWidget *OptirunButton; GtkWidget *PrimusrunCombo; GtkWidget *PrimusrunEntry; GtkWidget *PrimusrunButton; GtkWidget *FrameGapCombo; GtkWidget *DriversTree; GtkWidget *TopTree; GtkCellRenderer *ModuleRenderer; GtkCellRenderer *PackageRenderer; GtkWidget *KernelsCombo; GtkWidget *InfoButton; GtkWidget *DriverModulesTab; GtkWidget *DriversTab; GtkWidget *MainTabLabel; GtkWidget *DriversTabLabel; GtkWidget *InformationTabLabel; GtkWidget *InformationFrameLabel; GtkWidget *InformationOverlay; GtkWidget *InformationCompanyLogoImage; GtkWidget *InformationOverlay2; GtkWidget *InformationCompanyLogoImage2; GtkWidget *InformationLabel; GtkWidget *InformationLabel2; GtkWidget *TerminalOverlay; GtkWidget *TerminalBox; GtkWidget *TerminalRevealer; GtkWidget *TerminalInfoLabel; GtkWidget *TerminalMoreButton; GtkWidget *TerminalScroll; GtkWidget *TerminalMoreRevieler; GtkWidget *MenusTab; GtkWidget *LoadDriversButton; } main_window; typedef struct { template_config_fields config_str loaded_config; int configsize; int autoChooseDrivers; monitor_view monitor_visuals; monitor_config monitors; proprietary_config proprietary; dictionary *supported_resolutions; GtkListStore *list; GtkListStore *list2; char *failsafenVidia; char *failsafeATI; int descreteOnly; char *optirun; char *primusrun; int gapfix; config_str ports; int portssize; config_str resolutions; int resolutionssize; render_data status_render; dictionary *monitor_output_layers; GtkWidget *pack_box; int dblock; int save_config; main_window *widgets; } config; typedef struct { int main; int enable; int position; char *position_port; char *port; char *resolution; config_str resolutionCapabilities; int frequency; int rotation; char *stringparameters; int dpms; int resolution_size; int cvt; int reduced; int gtf; int show_usupported; } monitorconfig; typedef struct { GtkWidget *combo; GtkWidget *tree; } combo_tree; typedef struct { char *curport; config_str resolutions; int resolutionssize; GtkWidget *MainWindow; GtkWidget *StatusBox; GtkWidget *HeadLabel; GtkWidget *EnableConfigurationBox; GtkWidget *InterfaceConfigurationBox; GtkWidget *EnableCheck; GtkWidget *PortCombo; GtkWidget *MainCheck; GtkWidget *ResolutionCombo; GtkWidget *UnsupportedCheck; GtkWidget *FrequencyCombo; GtkWidget *RotationCombo; GtkWidget *PositionPosCombo; GtkWidget *PositionPortCombo; GtkWidget *DoNotSwitchOffCheck; GtkWidget *ModelineCVTCheck; GtkWidget *UseCVTReducedCheck; GtkWidget *ModelineGTFCheck; GtkWidget *ParameterLineCheck; GtkWidget *ParameterLineEntry; GtkWidget *CancelButton; GtkWidget *SaveButton; } monitor_edit_window; typedef struct { GtkWidget *ScreenOverlay; GtkWidget *MonitorImage; GtkWidget *MonitorInfoBox; GtkWidget *NameLabel; GtkWidget *ResoulutionLabel; GtkWidget *DeleteButton; GtkWidget *SwitchButton; GtkWidget *ConfigureButton; GtkWidget *AddButton; } monitor_data; typedef struct { GtkWidget *window; GtkWidget *propriearyTreeView; GtkTreeViewColumn *ProprietaryDriverColumn; GtkTreeViewColumn *ProprietaryDescriptionColumn; GtkListStore *list; GtkWidget *ProprietaryCloseButton; GtkWidget *ProprietaryAcceptButton; } driver_window; monitor_data *yon_monitor_new(main_window *widgets,int dull); void yon_launch_with_output(char *command); void yon_monitor_view_update(); void on_save_done(main_window *, config_str output, int size); void yon_proprietary_get_thread(GtkWidget *self,main_window *widgets); void on_terminal_done(GtkWidget *terminal, int size, main_window *widgets); void on_terminal_more(GtkWidget *self, main_window *widgets); void on_terminal_destroy(GtkWidget *self, main_window *widgets); void on_terminal_check_progress(VteTerminal *terminal, main_window *widgets); void yon_terminal_start(main_window *widgets, char *usr_command); void on_driver_pack_selection_change(GtkWidget *self, main_window *widgets); void on_driver_pack_info(GtkWidget *self, main_window *widgets); void on_pack_install_activate(GtkCellRendererToggle* self,gchar* path,main_window *widgets); void on_module_install_activate(GtkCellRendererToggle* self,gchar* path,main_window *widgets); gboolean yon_filter_func(GtkTreeModel* model,GtkTreeIter* iter,main_window *widgets); void on_kernel_filter_changed(GtkWidget *self, main_window *widgets); void on_port_chosen_changed(GtkWidget *self, monitor_edit_window *window); void on_sensitive_change(GtkWidget *self, GtkWidget *toggle); void on_sensitive_change_reversed(GtkWidget *self, GtkWidget *toggle); void on_auto_choose_drivers(GtkWidget *self, main_window *widgets); void on_resolutions_unsupported_show(GtkToggleButton *self, monitor_edit_window *window); void yon_interface_save(); void yon_interface_update(); void yon_load_proceed(YON_CONFIG_TYPE type); void on_config_local_load(GtkWidget *self,main_window *widgets); void on_config_global_load(GtkWidget *self,main_window *widgets); void on_config_custom_load(GtkWidget *self,main_window *widgets); void on_config_global_local_save(); void on_config_local_save(); void on_config_global_save(); void on_config_custom_save(GtkWidget *self, main_window *widgets); void on_monitor_delete(GtkWidget *self,monitor_data *window); void on_monitor_switch(GtkWidget *self,monitor_data *window); void on_monitor_add(GtkWidget *self,main_window *widgets); void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window); void yon_monitor_parse(monitor_edit_window *window, char *string); void on_monitor_configure(GtkWidget *self,monitor_data *window); void yon_monitor_view_update(); void *yon_proprietary_local_get(main_window *widgets); void yon_proprietary_get_thread(GtkWidget *self,main_window *widgets); void yon_monitor_view_dictionary_destroy(void *window); monitor_data *yon_monitor_new(main_window *widgets,int dull); void yon_monitor_set_resolutions(); void yon_adapter_window_setup(main_window *widgets); void yon_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); void on_database_update(void *self,void *widgets); template_main_window *yon_main_window_complete(main_window *widgets); void config_init(); #endif