├── Makefile
├── README.md
├── README.rus.md
├── debian
├── startup-settings-amd64.deb
└── startup-settings-i386.deb
└── src
├── Makefile
├── autostart.cpp
├── autostart.hpp
├── fs.cpp
├── fs.hpp
├── gui.cpp
├── gui.glade
├── gui.hpp
├── item.cpp
├── item.hpp
├── main.cpp
├── startup-settings.desktop
└── util.hpp
/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | make -C src/ -s release
3 |
4 | install:
5 | cp startup-settings /usr/bin/
6 | cp src/startup-settings.desktop /usr/share/applications/
7 | mkdir -p /usr/share/startup-settings/
8 | cp src/gui.glade /usr/share/startup-settings/
9 | chmod -R 755 /usr/share/startup-settings/
10 |
11 | uninstall:
12 | rm -f /usr/bin/startup-settings
13 | rm -f /usr/share/startup-settings/gui.glade
14 | rm -f /usr/share/applications/startup-settings.desktop
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Language: **[Русский](/README.rus.md)|English**
2 |
3 | # Startup Settings
4 |
5 | There is no handy tool to control startup in GNOME 3. If you want to add a custom command to
6 | startup, you have to create file `~/.config/autostart/file.desktop` manually. This
7 | simple program written in C++ and GTK 3 provides user friendly graphical interface for
8 | startup managing. The program is designed especially for GNOME 3, however it can also be
9 | used in any other desktop environment.
10 |
11 | ### Installation
12 |
13 | If you are using Debian/Ubuntu, you can install the application from package
14 |
15 | For amd64:
16 | `wget https://github.com/hant0508/startup-settings/raw/master/debian/startup-settings-amd64.deb`
17 | `sudo dpkg -i startup-settings-amd64.deb`
18 | For i386:
19 | `wget https://github.com/hant0508/startup-settings/raw/master/debian/startup-settings-i386.deb`
20 | `sudo dpkg -i startup-settings-i386.deb`
21 |
22 | If you've installed the package, you don't need to build the program from source code, go to [usage](#usage).
23 |
24 | ### Building
25 |
26 | - Installing dependencies
27 | Debian/Ubuntu: `sudo apt-get install g++ make git libgtk-3-dev`
28 | Arch/Manjaro x32: `sudo pacman -S gcc git make gtk3`
29 | Arch/Manjaro x64: `sudo pacman -S gcc-multilib git make gtk3`
30 | - Building
31 | `git clone https://github.com/hant0508/startup-settings.git`
32 | `cd startup-settings`
33 | `make`
34 | - Installing application
35 | `sudo make install`
36 |
37 | To save the disk space, you can delete all the downloaded files and dependencies after the installation.
38 |
39 | ### Usage
40 |
41 | After the installation you can find the program in application menu or run
42 | `startup-settings` in terminal.
43 |
44 | Enter startup command into the `Command` field. It can be:
45 | - full path to file: `/usr/bin/file.sh`
46 | - relative path to file in your your home directory: `scripts/file.sh`
47 | - command from [$PATH](https://en.wikipedia.org/wiki/PATH_(variable)): `firefox`
48 |
49 | Depending on the window manager, you can also use drag-and-drop. GNOME 3 allow
50 | even drag and drop files.
51 |
52 | ### Screenshots
53 |
54 |  | 
55 | :---:|:---:
56 | Usage on GNOME 3 | Drag and drop on GNOME 3
57 |
58 |
59 |  |  | 
60 | :-------------------------:|:-------------------------:|:-------------------------:
61 | KDE 5 | Cinnamon 3 | XFCE 4
62 |
63 | ### Feedback
64 |
65 | If you have any problems with the application, [open an
66 | issue](https://github.com/hant0508/startup-settings/issues/new). Write me [at
67 | email](mailto:hant0508@gmail.com?subject=GitHub issue | Startup), if you have no
68 | GitHub account.
69 |
--------------------------------------------------------------------------------
/README.rus.md:
--------------------------------------------------------------------------------
1 | Language: **Русский|[English](/README.md)**
2 |
3 | # Startup Settings
4 |
5 | По умолчанию в GNOME 3 отсутствуют удобные инструменты для управления автозагрузкой.
6 | Для добавления пользовательской команды в автозагрузку необходимо вручную создать
7 | файл `~/.config/autostart/file.desktop`. Эта небольшая программа, написанная на C++ и
8 | GTK 3, предоставляет удобный графический интерфейс для управления автозагрузкой.
9 | Программа разработана специально для GNOME 3, однако может быть использована и в
10 | любой другой среде рабочего стола.
11 |
12 | ### Установка
13 |
14 | Если вы используете Debian/Ubuntu, вы можете установить приложение из пакета.
15 |
16 | Для amd64:
17 | `wget https://github.com/hant0508/startup-settings/raw/master/debian/startup-settings-amd64.deb`
18 | `sudo dpkg -i startup-settings-amd64.deb`
19 | Для i386:
20 | `wget https://github.com/hant0508/startup-settings/raw/master/debian/startup-settings-i386.deb`
21 | `sudo dpkg -i startup-settings-i386.deb`
22 |
23 | Если вы установили пакет, то вам не нужно собирать программу из исходного кода, переходите к [использованию](#Использование).
24 |
25 | ### Сборка
26 |
27 | - Установка зависимостей
28 | Debian/Ubuntu: `sudo apt-get install g++ make git libgtk-3-dev`
29 | Arch/Manjaro x32: `sudo pacman -S gcc git make gtk3`
30 | Arch/Manjaro x64: `sudo pacman -S gcc-multilib git make gtk3`
31 | - Сборка
32 | `git clone https://github.com/hant0508/startup-settings.git`
33 | `cd startup-settings`
34 | `make`
35 | - Установка приложения
36 | `sudo make install`
37 |
38 | Для освобождения места на диске вы можете удалить все загруженные файлы и зависимости
39 | после установки приложения.
40 |
41 | ### Использование
42 |
43 | После установки вы сможете найти программу в меню приложений или запустить
44 | `startup-settings` из терминала.
45 |
46 | Введите в поле `Command` команду автозагрузки. Это может быть:
47 | - полный путь к файлу: `/usr/bin/file.sh`
48 | - относительный путь к файлу в домашней папке: `scripts/file.sh`
49 | - команда из [$PATH](https://ru.wikipedia.org/wiki/PATH_(%D0%BF%D0%B5%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F)): `firefox`
50 |
51 | В зависимости от оконного менеджера, вы так же можете использовать drag-and-drop
52 | (перетаскивание). GNOME 3 разрешает даже перетаскивать файлы.
53 |
54 | ### Скриншоты
55 |
56 |  | 
57 | :---:|:---:
58 | Usage on GNOME 3 | Drag and drop on GNOME 3
59 |
60 |  |  | 
61 | :-------------------------:|:-------------------------:|:-------------------------:
62 | KDE 5 | Cinnamon 3 | XFCE 4
63 |
64 | ### Обратная связь
65 |
66 | Если у вас возникли проблемы при работе с программой, сообщите о них на
67 | [GitHub](https://github.com/hant0508/startup-settings/issues/new) или
68 | [Вконтакте](https://vk.com/im?sel=116615188). Пишите мне [по электронной
69 | почте](mailto:hant0508@gmail.com?subject=GitHub issue | Startup), если у вас нет
70 | аккаунта на GitHub.
71 |
--------------------------------------------------------------------------------
/debian/startup-settings-amd64.deb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hant0508-zz/startup-settings/6b1cc1700bb7f69babd0eff86dc7ca0505630ec5/debian/startup-settings-amd64.deb
--------------------------------------------------------------------------------
/debian/startup-settings-i386.deb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hant0508-zz/startup-settings/6b1cc1700bb7f69babd0eff86dc7ca0505630ec5/debian/startup-settings-i386.deb
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | CC=g++
2 | #CC=clang++
3 | ACFLAGS = -O2
4 | #ACFLAGS = -Wall -g
5 | CFLAGS = -c -std=c++11 `pkg-config --cflags gtk+-3.0`
6 | LDFLAGS= -rdynamic `pkg-config --libs gtk+-3.0`
7 | SOURCES=main.cpp gui.cpp autostart.cpp item.cpp fs.cpp
8 | OBJECTS=$(SOURCES:.cpp=.o)
9 | EXECUTABLE=startup-settings
10 |
11 | all: $(SOURCES) $(EXECUTABLE)
12 |
13 | $(EXECUTABLE): $(OBJECTS)
14 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@
15 |
16 | .cpp.o:
17 | $(CC) $(CFLAGS)$(ACFLAGS) $< -o $@
18 |
19 | remake: clean all
20 |
21 | debug: clean all
22 | gdb ./$(EXECUTABLE)
23 |
24 | run: all
25 | ./$(EXECUTABLE)
26 |
27 | release: all clean
28 | cp $(EXECUTABLE) ../
29 |
30 | clean:
31 | rm -f $(OBJECTS)
32 |
--------------------------------------------------------------------------------
/src/autostart.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2016 Dmitry Ivanov
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include "item.hpp"
31 | #include "autostart.hpp"
32 | #include "fs.hpp"
33 | #include "util.hpp"
34 |
35 | Autostart::Autostart ()
36 | {
37 | if (!fs::exists (fs::home (S_CONFIG_PATH), true))
38 | fs::mkdir (fs::home (S_CONFIG_PATH));
39 | fs::cd (fs::home (S_CONFIG_PATH));
40 | scan_folder();
41 | }
42 |
43 | std::string Autostart::file_name (Item &it) const
44 | {
45 | std::string fname = it.get_name() + S_EXTENSION;
46 |
47 | for (size_t i = 0; i < fname.size(); ++i)
48 | if (fname.at(i) == '/') fname.at(i) = '_';
49 |
50 | for (int i = 1; fs::exists (fs::pwd() + fname, true); ++i)
51 | fname = it.get_name() + std::to_string (i) + S_EXTENSION;
52 |
53 | it.set_id (fname);
54 | return fname;
55 | }
56 |
57 | bool Autostart::add_element (Item &it)
58 | {
59 | if (it.get_cmd() == S_EMPTY) return false;
60 | if (it.get_name() == S_EMPTY) it.set_name ("unnamed");
61 |
62 | std::string fname = file_name (it);
63 |
64 | std::ofstream file (fs::pwd() + fname);
65 |
66 | file << "[Desktop Entry]\n";
67 | file << "Name=" << it.get_name() << "\n";
68 | file << "Comment=" << it.get_comment() << "\n";
69 | file << "Exec=" << it.get_cmd() << "\n";
70 | file << "Terminal=" << it.get_term() << "\n";
71 | file << "Type=Application";
72 |
73 | file.close();
74 |
75 | list_.emplace (std::make_pair (fname, it));
76 |
77 | return true;
78 | }
79 |
80 | void Autostart::remove_element (const std::string &id)
81 | {
82 | std::remove (std::string (fs::pwd() + id).c_str());
83 |
84 | for (auto i = list_.begin(); i != list_.end(); ++i)
85 | if (i->first == id)
86 | {
87 | i = list_.erase (i);
88 | break;
89 | }
90 | }
91 |
92 | void Autostart::scan_folder ()
93 | {
94 | std::vector f, files;
95 | f = fs::ls();
96 |
97 | for (size_t i = 0; i < f.size(); ++i)
98 | {
99 | std::string fname = f.at(i);
100 | std::string test1 = fs::find_in_file (std::regex ("\\[Desktop Entry\\]"), fs::pwd() + fname);
101 | std::string test2 = fs::find_in_file (std::regex ("X\\-.*\\-Autostart\\-enabled=false"), fs::pwd() + fname);
102 |
103 | if (test1 != S_EMPTY && test2 == S_EMPTY) files.push_back (fname);
104 | }
105 |
106 | for (size_t i = 0; i < files.size(); ++i)
107 | {
108 | std::string cmd = fs::find_in_file (std::regex ("Exec=.*"), fs::pwd() + files.at(i));
109 | std::string name = fs::find_in_file (std::regex ("Name=.*"), fs::pwd() + files.at(i));
110 | std::string comment = fs::find_in_file (std::regex ("Comment=.*"), fs::pwd() + files.at(i));
111 | std::string sterm = fs::find_in_file (std::regex ("Terminal= *true"), fs::pwd() + files.at(i));
112 |
113 | if (cmd != S_EMPTY) cmd = cmd.substr (5);
114 | if (name != S_EMPTY) name = name.substr (5);
115 | if (comment != S_EMPTY) comment = comment.substr (8);
116 | bool term = (sterm == S_EMPTY ? false : true);
117 |
118 | Item it (cmd, name, comment, term);
119 | it.set_id (files.at(i));
120 | list_.emplace (std::make_pair (files.at(i), it));
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/autostart.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2016 Dmitry Ivanov
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #ifndef AUTOSTART_HPP
27 | #define AUTOSTART_HPP
28 |
29 | #include