Added sway support and created initial xp overlay with gtk-layer-shell

This commit is contained in:
2025-06-15 01:31:43 -06:00
parent d34cccc253
commit 4c07690e85
151 changed files with 7290 additions and 247 deletions
+72 -10
View File
@@ -7,15 +7,23 @@ import 'package:xp_nix/src/config/config_manager.dart';
import 'package:xp_nix/src/logging/logger.dart';
import 'package:xp_nix/src/web/dashboard_server.dart';
import 'package:xp_nix/src/database/database_manager.dart';
import 'package:xp_nix/src/detectors/idle_monitor.dart';
import 'package:xp_nix/src/providers/system_time_provider.dart';
import 'package:xp_nix/src/enhancers/hyprland_enhancer.dart';
import 'package:xp_nix/src/build/dashboard_builder.dart';
// Window manager detection and factories
import 'package:xp_nix/src/detectors/window_manager_detector.dart';
import 'package:xp_nix/src/factories/idle_monitor_factory.dart';
import 'package:xp_nix/src/factories/activity_detector_factory.dart';
import 'package:xp_nix/src/factories/desktop_enhancer_factory.dart';
// Interfaces
import 'package:xp_nix/src/interfaces/i_idle_monitor.dart';
import 'package:xp_nix/src/interfaces/i_activity_detector.dart';
import 'package:xp_nix/src/interfaces/i_desktop_enhancer.dart';
late final Database _db;
late final IdleMonitor _idleMonitor;
late final IIdleMonitor _idleMonitor;
late final SystemTimeProvider _timeProvider;
late final HyprlandEnhancer _desktopEnhancer;
late final IDesktopEnhancer _desktopEnhancer;
late final IActivityDetector? _activityDetector;
late final ProductivityMonitor _monitor;
late final DashboardServer _dashboardServer;
@@ -48,7 +56,10 @@ void main(List<String> args) async {
case '--help':
case '-h':
print('''
XP Nix Server
XP Nix Server - Productivity Tracking with Gamification
A productivity tracking system that works with both Hyprland and Sway window managers.
Automatically detects your environment and adapts functionality accordingly.
Usage: dart xp_nix.dart [options]
@@ -57,9 +68,18 @@ Options:
--port PORT Server port (default: 8080)
--help, -h Show this help message
Supported Window Managers:
• Hyprland: Full visual effects, idle monitoring, activity detection
• Sway: Activity detection, idle monitoring (no visual effects)
• Detection: Automatic via environment variables
Examples:
dart xp_nix.dart
dart xp_nix.dart --db test_data.db --port 8081
Requirements:
• Hyprland: hypridle, hyprctl
• Sway: swayidle, swaymsg
''');
exit(0);
}
@@ -74,12 +94,54 @@ Examples:
// Initialize configuration manager
await ConfigManager.instance.initialize();
// Detect window manager and display information
final windowManager = WindowManagerDetector.instance.detect();
final detectionInfo = WindowManagerDetector.instance.getDetectionInfo();
print('🖼️ Detected window manager: ${windowManager.toString()}');
print(' Detection method: ${detectionInfo['detection_method']}');
// Log additional environment info
Logger.info('Window manager detection: $detectionInfo');
_db = sqlite3.open(dbPath);
// Create production dependencies
_idleMonitor = IdleMonitor();
_timeProvider = SystemTimeProvider();
_desktopEnhancer = HyprlandEnhancer();
// Create window manager-specific dependencies using factories
try {
_idleMonitor = IdleMonitorFactory.create(windowManager);
_desktopEnhancer = DesktopEnhancerFactory.create(windowManager);
_activityDetector = ActivityDetectorFactory.create(windowManager);
_timeProvider = SystemTimeProvider();
// Validate requirements for the detected window manager
final idleSupported = await IdleMonitorFactory.validateRequirements(windowManager);
final activitySupported = await ActivityDetectorFactory.validateRequirements(windowManager);
final enhancerSupported = await DesktopEnhancerFactory.validateRequirements(windowManager);
print('💡 Component availability:');
print(' Idle monitoring: ${idleSupported ? '' : ''}');
print(' Activity detection: ${activitySupported ? '' : ''}');
print(' Visual enhancements: ${enhancerSupported ? '' : ''}');
if (!idleSupported) {
print(' ⚠️ Idle monitoring may not work properly');
}
if (!activitySupported) {
print(' ⚠️ Activity detection will fall back to legacy polling');
}
if (!enhancerSupported) {
print(' ⚠️ Visual enhancements may be limited');
}
} catch (e) {
print('❌ Error creating window manager components: $e');
print(' Falling back to legacy mode...');
// Fallback to original Hyprland implementations (import at top of file)
// Note: This requires adding imports back if needed
Logger.error('Component creation failed, falling back to legacy mode: $e');
exit(1); // For now, exit on component creation failure
}
// Create monitor with dependency injection
_monitor = ProductivityMonitor(
@@ -87,7 +149,7 @@ Examples:
idleMonitor: _idleMonitor,
timeProvider: _timeProvider,
desktopEnhancer: _desktopEnhancer,
// No activity detector provided - will use legacy polling mode
activityDetector: _activityDetector, // May be null for fallback to legacy polling
);
_dashboardServer = DashboardServer.withDatabase(DatabaseManager(_db));