mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 18:49:49 +01:00
Added default config & warning about it
This commit is contained in:
parent
7347a72ba6
commit
7449a0c44c
4 changed files with 98 additions and 5 deletions
|
@ -40,6 +40,8 @@ CConfigManager::CConfigManager() {
|
|||
configValues["input:kb_options"].strValue = "";
|
||||
configValues["input:kb_rules"].strValue = "";
|
||||
configValues["input:kb_model"].strValue = "";
|
||||
|
||||
configValues["autogenerated"].intValue = 0;
|
||||
}
|
||||
|
||||
void CConfigManager::init() {
|
||||
|
@ -289,14 +291,27 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||
|
||||
std::ifstream ifs;
|
||||
ifs.open(CONFIGPATH.c_str());
|
||||
ifs.open(CONFIGPATH);
|
||||
|
||||
if (!ifs.good()) {
|
||||
Debug::log(WARN, "Config reading error. (No file?)");
|
||||
parseError = "The config could not be read. (No file?)";
|
||||
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
||||
try {
|
||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||
} catch(...) { /* Probably doesn't exist */}
|
||||
|
||||
ifs.close();
|
||||
return;
|
||||
std::ofstream ofs;
|
||||
ofs.open(CONFIGPATH, std::ios::trunc);
|
||||
|
||||
ofs << AUTOCONFIG;
|
||||
|
||||
ofs.close();
|
||||
|
||||
ifs.open(CONFIGPATH);
|
||||
|
||||
if (!ifs.good()) {
|
||||
parseError = "Broken config file! (Could not open)";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string line = "";
|
||||
|
@ -335,6 +350,8 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
// parseError will be displayed next frame
|
||||
if (parseError != "")
|
||||
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
||||
else if (configValues["autogenerated"].intValue == 1)
|
||||
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Enter -> kitty\nSUPER+T -> Alacritty\nSUPER+M -> exit Hyprland", CColor(255, 255, 70, 255));
|
||||
else
|
||||
g_pHyprError->destroy();
|
||||
}
|
||||
|
@ -344,6 +361,11 @@ void CConfigManager::tick() {
|
|||
|
||||
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||
|
||||
if (!std::filesystem::exists(CONFIGPATH)) {
|
||||
loadConfigLoadVars();
|
||||
return;
|
||||
}
|
||||
|
||||
struct stat fileStat;
|
||||
int err = stat(CONFIGPATH.c_str(), &fileStat);
|
||||
if (err != 0) {
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <regex>
|
||||
#include "../Window.hpp"
|
||||
|
||||
#include "defaultConfig.hpp"
|
||||
|
||||
struct SConfigValue {
|
||||
int64_t intValue = -1;
|
||||
float floatValue = -1;
|
||||
|
|
68
src/config/defaultConfig.hpp
Normal file
68
src/config/defaultConfig.hpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
inline const std::string AUTOCONFIG = R"#(
|
||||
########################################################################################
|
||||
AUTOGENERATED HYPR CONFIG.
|
||||
PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT,
|
||||
OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
|
||||
########################################################################################
|
||||
|
||||
autogenerated=1 # remove this line to get rid of the warning on top.
|
||||
|
||||
monitor=,1920x1080@60,0x0,0.5,1
|
||||
|
||||
input {
|
||||
kb_layout=
|
||||
kb_variant=
|
||||
kb_model=
|
||||
kb_options=
|
||||
kb_rules=
|
||||
}
|
||||
|
||||
general {
|
||||
max_fps=60
|
||||
sensitivity=0.25
|
||||
main_mod=SUPER
|
||||
|
||||
gaps_in=5
|
||||
gaps_out=20
|
||||
border_size=2
|
||||
col.active_border=0x66ee1111
|
||||
col.inactive_border=0x66333333
|
||||
}
|
||||
|
||||
decoration {
|
||||
rounding=10
|
||||
}
|
||||
|
||||
animations {
|
||||
enabled=1
|
||||
speed=7
|
||||
windows_speed=6 # specific speeds for components can be made with name_speed=float. 0 means use global (speed=float). If not set, will use the global value.
|
||||
windows=1
|
||||
borders=1
|
||||
borders_speed=20
|
||||
fadein=1 # fade in AND out
|
||||
fadein_speed=20
|
||||
}
|
||||
|
||||
# basic binds
|
||||
bind=SUPER,return,exec,kitty
|
||||
bind=SUPER,T,exec,alacritty
|
||||
bind=SUPER,C,killactive,
|
||||
bind=SUPER,M,exec,pkill Hyprland
|
||||
bind=SUPER,V,togglefloating,
|
||||
|
||||
bind=SUPER,1,workspace,1
|
||||
bind=SUPER,2,workspace,2
|
||||
bind=SUPER,3,workspace,3
|
||||
bind=SUPER,4,workspace,4
|
||||
bind=SUPER,5,workspace,5
|
||||
bind=SUPER,6,workspace,6
|
||||
bind=SUPER,7,workspace,7
|
||||
bind=SUPER,8,workspace,8
|
||||
bind=SUPER,9,workspace,9
|
||||
bind=SUPER,0,workspace,10
|
||||
)#";
|
|
@ -19,6 +19,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
#if true
|
||||
|
|
Loading…
Reference in a new issue