mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-12-25 02:39:49 +01:00
Added autogenerated config + warning
This commit is contained in:
parent
5b71f65ec8
commit
6f5172dd32
5 changed files with 116 additions and 6 deletions
|
@ -431,10 +431,13 @@ int CStatusBar::getTextHalfY() {
|
|||
}
|
||||
|
||||
void CStatusBar::drawErrorScreen() {
|
||||
drawCairoRectangle(Vector2D(0, 0), m_vecSize, 0xFFaa1111);
|
||||
if (ConfigManager::getInt("autogenerated") == 1)
|
||||
drawCairoRectangle(Vector2D(0, 0), m_vecSize, 0xffffff33);
|
||||
else
|
||||
drawCairoRectangle(Vector2D(0, 0), m_vecSize, 0xFFaa1111);
|
||||
|
||||
drawText(Vector2D(1, getTextHalfY()), ConfigManager::parseError, 0xff000000, ConfigManager::getString("bar:font.main"));
|
||||
|
||||
|
||||
// do all the drawing cuz we return later
|
||||
cairo_surface_flush(m_pCairoSurface);
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ void ConfigManager::init() {
|
|||
configValues["animations:borders"].intValue = 1;
|
||||
configValues["animations:workspaces"].intValue = 0;
|
||||
|
||||
configValues["autogenerated"].intValue = 0;
|
||||
|
||||
if (!g_pWindowManager->statusBar) {
|
||||
isFirstLaunch = true;
|
||||
}
|
||||
|
@ -348,11 +350,25 @@ void ConfigManager::loadConfigLoadVars() {
|
|||
ifs.open(CONFIGPATH.c_str());
|
||||
|
||||
if (!ifs.good()) {
|
||||
Debug::log(WARN, "Config reading error. (No file?)");
|
||||
ConfigManager::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 = "";
|
||||
|
@ -383,6 +399,10 @@ void ConfigManager::loadConfigLoadVars() {
|
|||
// recalc all workspaces
|
||||
g_pWindowManager->recalcAllWorkspaces();
|
||||
|
||||
if (configValues["autogenerated"].intValue == 1) {
|
||||
parseError = "Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " ) SUPER+Enter -> xterm SUPER+T -> Alacritty SUPER+M -> exit Hypr";
|
||||
}
|
||||
|
||||
// Reload the bar as well, don't load it before the default is loaded.
|
||||
if (loadBar && g_pWindowManager->statusBar && (configValues["bar:enabled"].intValue == 1 || parseError != "")) {
|
||||
g_pWindowManager->statusBar->destroy();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "../defines.hpp"
|
||||
#include <vector>
|
||||
|
||||
#include "defaultConfig.hpp"
|
||||
|
||||
enum ELayouts {
|
||||
LAYOUT_DWINDLE = 0,
|
||||
LAYOUT_MASTER
|
||||
|
|
84
src/config/defaultConfig.hpp
Normal file
84
src/config/defaultConfig.hpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#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.
|
||||
|
||||
gaps_in=5
|
||||
border_size=1
|
||||
gaps_out=20
|
||||
rounding=0
|
||||
max_fps=60 # max fps for updates of config & animations
|
||||
focus_when_hover=1 # 0 - do not switch the focus when hover (only for tiling)
|
||||
main_mod=SUPER # For moving, resizing
|
||||
intelligent_transients=1 # keeps transients always on top.
|
||||
no_unmap_saving=1 # disables saving unmapped windows (seems to break sometimes)
|
||||
scratchpad_mon=0 # self-explanatory
|
||||
|
||||
# Layout
|
||||
layout=0 # 0 - dwindle (default), 1 - master
|
||||
layout {
|
||||
no_gaps_when_only=0 # disables gaps and borders when only window on screen
|
||||
}
|
||||
|
||||
# Bar config
|
||||
Bar {
|
||||
height=20
|
||||
monitor=0
|
||||
enabled=1
|
||||
mod_pad_in=8
|
||||
no_tray_saving=1 # using this doesnt save the tray between reloads but fixes an issue with the bar disappearing.
|
||||
|
||||
font.main=Noto Sans
|
||||
font.secondary=Noto Sans
|
||||
|
||||
col.bg=0xff111111
|
||||
col.high=0xffff3333
|
||||
|
||||
module=left,X,0xff8000ff,0xffffffff,1,workspaces
|
||||
module=pad,left,10
|
||||
module=left,,0xff7000dd,0xff7000dd,1,tray
|
||||
module=right,X,0xffffffff,0xff00ff33,1000,$date +%a,\ %b\ %Y\ \ %I:%M\ %p$
|
||||
}
|
||||
|
||||
# colors
|
||||
col.active_border=0x77ff3333
|
||||
col.inactive_border=0x77222222
|
||||
|
||||
# animations
|
||||
Animations {
|
||||
enabled=1
|
||||
speed=5
|
||||
cheap=1 # highly recommended
|
||||
borders=0
|
||||
workspaces=0 # not really recommended
|
||||
}
|
||||
|
||||
# keybinds
|
||||
bind=SUPER,R,exec,dmenu_run
|
||||
bind=SUPER,T,exec,alacritty
|
||||
bind=SUPER,M,exec,pkill Hypr
|
||||
bind=SUPER,RETURN,exec,xterm
|
||||
bind=SUPER,G,exec,google-chrome-stable
|
||||
|
||||
bind=SUPER,C,killactive,
|
||||
|
||||
bind=SUPER,F,fullscreen,
|
||||
|
||||
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
|
||||
)#";
|
|
@ -30,6 +30,7 @@
|
|||
#include <unordered_map>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#include "./helpers/Vector.hpp"
|
||||
#include "./utilities/Debug.hpp"
|
||||
|
|
Loading…
Reference in a new issue